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

Unified Diff: net/base/dns_util.cc

Issue 919023003: DNSDomainFromDot: Reject empty labels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 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 | « no previous file | net/base/dns_util_unittest.cc » ('j') | net/dns/host_resolver_proc.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/dns_util.cc
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc
index f75cd956663e77123cb90a8614cdba27b667f6f7..9afaf4faec903234bc27c11202169c04d25407a9 100644
--- a/net/base/dns_util.cc
+++ b/net/base/dns_util.cc
@@ -24,14 +24,15 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
ch = *buf++;
--n;
if (ch == '.') {
- if (labellen) {
- if (namelen + labellen + 1 > sizeof name)
- return false;
- name[namelen++] = static_cast<char>(labellen);
- memcpy(name + namelen, label, labellen);
- namelen += labellen;
- labellen = 0;
- }
+ // Don't allow empty labels per http://crbug.com/456391.
+ if (!labellen)
+ return false;
+ if (namelen + labellen + 1 > sizeof name)
+ return false;
+ name[namelen++] = static_cast<char>(labellen);
+ memcpy(name + namelen, label, labellen);
+ namelen += labellen;
+ labellen = 0;
continue;
}
if (labellen >= sizeof label)
@@ -39,6 +40,7 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
label[labellen++] = ch;
}
+ // Allow empty label at end of name to disable suffix search.
if (labellen) {
if (namelen + labellen + 1 > sizeof name)
return false;
« no previous file with comments | « no previous file | net/base/dns_util_unittest.cc » ('j') | net/dns/host_resolver_proc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698