Commit 4c511204 authored by eroman's avatar eroman Committed by Commit bot

Harden an API that takes base::StringPiece to give a compile error if

ever a naked const char* is passed in.

I hit this bug while doing a refactor, so ensuring it can't happen
again for this callsite seems prudent.

BUG=634443

Review-Url: https://codereview.chromium.org/2331323005
Cr-Commit-Position: refs/heads/master@{#418593}
parent 74dde3a9
......@@ -227,6 +227,24 @@ class NET_EXPORT ParsedCertificate
const ParseCertificateOptions& options,
CertErrors* errors);
// These private overloads should not be used, and have no definition.
//
// They are here to prevent incorrectly passing a const char*
// in place of a base::StringPiece (thanks to StringPiece implicit
// ctor on const char*).
//
// Accidentally inflating a const char* (without length) to a
// StringPiece would be a bug.
static scoped_refptr<ParsedCertificate> Create(
const char* invalid_data,
const ParseCertificateOptions& options,
CertErrors* errors);
static bool CreateAndAddToVector(
const char* data,
const ParseCertificateOptions& options,
std::vector<scoped_refptr<net::ParsedCertificate>>* chain,
CertErrors* errors);
// The backing store for the certificate data. This is only applicable when
// the ParsedCertificate was initialized using DataSource::INTERNAL_COPY.
std::vector<uint8_t> cert_data_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment