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

Unified Diff: net/cert/internal/name_constraints.cc

Issue 1546653004: Name constraints with excluded names but no permitted names should allow names not matching the exc… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/cert/internal/name_constraints_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/name_constraints.cc
diff --git a/net/cert/internal/name_constraints.cc b/net/cert/internal/name_constraints.cc
index 07e231e4d2331c7b15e65e1fc4ff5ddb73cad7db..68455c7bcba10f05fd8fda1e6584edc209fac317 100644
--- a/net/cert/internal/name_constraints.cc
+++ b/net/cert/internal/name_constraints.cc
@@ -505,6 +505,12 @@ bool NameConstraints::IsPermittedDNSName(const std::string& name) const {
if (DNSNameMatches(name, excluded_name, WILDCARD_PARTIAL_MATCH))
return false;
}
+
+ // If permitted subtrees are not constrained, any name that is not excluded is
+ // allowed.
+ if (!(permitted_subtrees_.present_name_types & GENERAL_NAME_DNS_NAME))
+ return true;
+
for (const std::string& permitted_name : permitted_subtrees_.dns_names) {
// When matching wildcard hosts against permitted subtrees, consider it a
// match only if the constraint would match all expansions of the wildcard.
@@ -530,6 +536,12 @@ bool NameConstraints::IsPermittedDirectoryName(
return false;
}
}
+
+ // If permitted subtrees are not constrained, any name that is not excluded is
+ // allowed.
+ if (!(permitted_subtrees_.present_name_types & GENERAL_NAME_DIRECTORY_NAME))
+ return true;
+
for (const auto& permitted_name : permitted_subtrees_.directory_names) {
if (VerifyNameInSubtree(
name_rdn_sequence,
@@ -551,6 +563,12 @@ bool NameConstraints::IsPermittedIP(const IPAddressNumber& ip) const {
if (IPNumberMatchesPrefix(ip, excluded_ip.first, excluded_ip.second))
return false;
}
+
+ // If permitted subtrees are not constrained, any name that is not excluded is
+ // allowed.
+ if (!(permitted_subtrees_.present_name_types & GENERAL_NAME_IP_ADDRESS))
+ return true;
+
for (const auto& permitted_ip : permitted_subtrees_.ip_address_ranges) {
if (IPNumberMatchesPrefix(ip, permitted_ip.first, permitted_ip.second))
return true;
« no previous file with comments | « no previous file | net/cert/internal/name_constraints_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698