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

Unified Diff: net/dns/dns_util.cc

Issue 2921553002: Track how often we successfully resolve non-'compliant' domain names. (Closed)
Patch Set: Created 3 years, 7 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
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);
« no previous file with comments | « net/dns/dns_util.h ('k') | net/dns/host_resolver_proc.cc » ('j') | net/dns/host_resolver_proc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698