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

Unified Diff: net/dns/dns_util.cc

Issue 2294343003: Refuse to resolve some types of invalid DNS addresses. (Closed)
Patch Set: NET_EXPORT_PRIVATE Created 4 years, 4 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 | « net/dns/dns_util.h ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_util.cc
diff --git a/net/dns/dns_util.cc b/net/dns/dns_util.cc
index 48be035c0e3380d37f5aa0d29e3406760b97db6d..716fb685daefd054129e30974a425f44919b2a3b 100644
--- a/net/dns/dns_util.cc
+++ b/net/dns/dns_util.cc
@@ -33,6 +33,10 @@ namespace net {
// Based on DJB's public domain code.
bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
+ // Refuse to convert invalid host names.
Julia Tuttle 2016/09/09 20:24:38 This is commented out; remove it?
mmenke 2016/09/09 20:38:44 Oops, thanks! I hadn't realized this was actually
+ // if (!IsHostnameValid(dotted))
+ // return false;
+
const char* buf = dotted.data();
unsigned n = dotted.size();
char label[63];
@@ -83,6 +87,11 @@ bool DNSDomainFromDot(const base::StringPiece& dotted, std::string* out) {
return true;
}
+bool IsValidDNSDomain(const base::StringPiece& dotted) {
+ std::string dns_formatted;
+ return DNSDomainFromDot(dotted, &dns_formatted);
+}
+
std::string DNSDomainToString(const base::StringPiece& domain) {
std::string ret;
« no previous file with comments | « net/dns/dns_util.h ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698