Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: net/cert/x509_util_nss.cc

Issue 2758803003: Make X509Certificate creation fail if X509Certificate::Initialize fails. (Closed)
Patch Set: test updatess 2 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/x509_util_nss.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/x509_util_nss.cc
diff --git a/net/cert/x509_util_nss.cc b/net/cert/x509_util_nss.cc
index 2988417673b0a2fadb044217032857bee4f7a15d..1175bd8054d27c9d56568de2e3a5650187e771fd 100644
--- a/net/cert/x509_util_nss.cc
+++ b/net/cert/x509_util_nss.cc
@@ -89,7 +89,7 @@ CERTName* CreateCertNameFromEncoded(PLArenaPool* arena,
namespace x509_util {
-void ParsePrincipal(CERTName* name, CertPrincipal* principal) {
+bool ParsePrincipal(CERTName* name, CertPrincipal* principal) {
// Starting in NSS 3.15, CERTGetNameFunc takes a const CERTName* argument.
#if NSS_VMINOR >= 15
typedef char* (*CERTGetNameFunc)(const CERTName* name);
@@ -120,7 +120,7 @@ void ParsePrincipal(CERTName* name, CertPrincipal* principal) {
if (kOIDs[oid] == tag) {
SECItem* decode_item = CERT_DecodeAVAValue(&avas[pair]->value);
if (!decode_item)
- break;
+ return false;
// TODO(wtc): Pass decode_item to CERT_RFC1485_EscapeAndQuote.
std::string value(reinterpret_cast<char*>(decode_item->data),
decode_item->len);
@@ -145,13 +145,17 @@ void ParsePrincipal(CERTName* name, CertPrincipal* principal) {
PORT_Free(value);
}
}
+
+ return true;
}
-void ParseDate(const SECItem* der_date, base::Time* result) {
+bool ParseDate(const SECItem* der_date, base::Time* result) {
PRTime prtime;
SECStatus rv = DER_DecodeTimeChoice(&prtime, der_date);
- DCHECK_EQ(SECSuccess, rv);
+ if (rv != SECSuccess)
+ return false;
*result = crypto::PRTimeToBaseTime(prtime);
+ return true;
}
std::string ParseSerialNumber(const CERTCertificate* certificate) {
« no previous file with comments | « net/cert/x509_util_nss.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698