Chromium Code Reviews| Index: net/cert/internal/parse_certificate.cc |
| diff --git a/net/cert/internal/parse_certificate.cc b/net/cert/internal/parse_certificate.cc |
| index 2c42facf23e181d50f60bc8e3520d56617c6cb2b..df2da3bccff0d394b0cf55957e460ab0b73cc16a 100644 |
| --- a/net/cert/internal/parse_certificate.cc |
| +++ b/net/cert/internal/parse_certificate.cc |
| @@ -30,6 +30,9 @@ DEFINE_CERT_ERROR_ID( |
| DEFINE_CERT_ERROR_ID(kSignatureValueNotBitString, |
| "Couldn't read Certificate.signatureValue as BIT STRING"); |
| +DEFINE_CERT_ERROR_ID(kUnconsumedDataInsideTbsCertificateSequence, |
| + "Unconsumed data inside TBSCertificate"); |
|
mattm
2016/09/16 21:41:48
should tbs be lowercase?
eroman
2016/09/16 22:07:18
I intentionally upper-cased it to refer to the typ
mattm
2016/09/16 22:16:44
ah, sounds good.
|
| + |
| // Returns true if |input| is a SEQUENCE and nothing else. |
| WARN_UNUSED_RESULT bool IsSequenceTLV(const der::Input& input) { |
| der::Parser parser(input); |
| @@ -258,7 +261,16 @@ bool ParseCertificate(const der::Input& certificate_tlv, |
| // } |
| bool ParseTbsCertificate(const der::Input& tbs_tlv, |
| const ParseCertificateOptions& options, |
| - ParsedTbsCertificate* out) { |
| + ParsedTbsCertificate* out, |
| + CertErrors* errors) { |
| + // The rest of this function assumes that |errors| is non-null. |
| + if (!errors) { |
| + CertErrors unused_errors; |
| + return ParseTbsCertificate(tbs_tlv, options, out, &unused_errors); |
| + } |
| + |
| + // TODO(crbug.com/634443): Add useful error information to |errors|. |
| + |
| der::Parser parser(tbs_tlv); |
| // Certificate ::= SEQUENCE { |
| @@ -374,8 +386,10 @@ bool ParseTbsCertificate(const der::Input& tbs_tlv, |
| // However because only v1, v2, and v3 certificates are supported by the |
| // parsing, there shouldn't be any subsequent data in those versions, so |
| // reject. |
| - if (tbs_parser.HasMore()) |
| + if (tbs_parser.HasMore()) { |
| + errors->AddError(kUnconsumedDataInsideTbsCertificateSequence); |
| return false; |
| + } |
| // By definition the input was a single TBSCertificate, so there shouldn't be |
| // unconsumed data. |