| Index: net/dns/dns_util.cc
|
| diff --git a/net/dns/dns_util.cc b/net/dns/dns_util.cc
|
| index 8eff1c6425eb204366eaf144b72e691b3f59c805..c08a3b59565c42600b9283af7fab6450e29a839f 100644
|
| --- a/net/dns/dns_util.cc
|
| +++ b/net/dns/dns_util.cc
|
| @@ -43,7 +43,9 @@ const int kMaxLabelLength = 63;
|
| namespace net {
|
|
|
| // Based on DJB's public domain code.
|
| -bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
|
| +bool DNSDomainFromDotWithValidityCheck(const base::StringPiece& dotted,
|
| + std::string* out,
|
| + bool* valid_name) {
|
| const char* buf = dotted.data();
|
| size_t n = dotted.size();
|
| char label[kMaxLabelLength];
|
| @@ -51,7 +53,7 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
|
| char name[dns_protocol::kMaxNameLength];
|
| size_t namelen = 0; /* <= sizeof name */
|
| char ch;
|
| - bool valid_name = true;
|
| + *valid_name = true;
|
|
|
| for (;;) {
|
| if (!n)
|
| @@ -73,14 +75,17 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
|
| if (labellen >= sizeof label)
|
| return false;
|
| if (!IsValidHostLabelCharacter(ch, labellen == 0)) {
|
| - // TODO(palmer): In the future, when we can remove support for invalid
|
| - // names, return false here instead (and remove the UMA counter).
|
| - valid_name = false;
|
| + // TODO(crbug.com/695474): In the future, when we can remove support for
|
| + // invalid names, return false here instead (and remove the UMA counter).
|
| + // And remove the |valid_name| parameter, rename this function back to
|
| + // |DNSDomainFromDot|, and remove the helper function by that name
|
| + // (below).
|
| + *valid_name = false;
|
| }
|
| label[labellen++] = ch;
|
| }
|
|
|
| - UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", valid_name);
|
| + UMA_HISTOGRAM_BOOLEAN("Net.ValidDNSName", *valid_name);
|
|
|
| // Allow empty label at end of name to disable suffix search.
|
| if (labellen) {
|
| @@ -102,6 +107,11 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
|
| return true;
|
| }
|
|
|
| +bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
|
| + bool ignored;
|
| + return DNSDomainFromDotWithValidityCheck(dotted, out, &ignored);
|
| +}
|
| +
|
| bool IsValidDNSDomain(const base::StringPiece& dotted) {
|
| std::string dns_formatted;
|
| return DNSDomainFromDot(dotted, &dns_formatted);
|
|
|