diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-10 14:43:00 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-10 14:43:00 +0000 |
commit | bfba36542e138194af9305cef85a00ffb9f4c548 (patch) | |
tree | 49714cf8afbdaeb12ac463a2328bdcd79601be0b /net/base/net_util.cc | |
parent | 735844ac9b440410b101127907090c17d3672852 (diff) | |
download | chromium_src-bfba36542e138194af9305cef85a00ffb9f4c548.zip chromium_src-bfba36542e138194af9305cef85a00ffb9f4c548.tar.gz chromium_src-bfba36542e138194af9305cef85a00ffb9f4c548.tar.bz2 |
Explicitly whitelist the test server port.
BUG=65859
TEST=yes please
Review URL: http://codereview.chromium.org/5519015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r-- | net/base/net_util.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 5426b68..4f6e361 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1052,7 +1052,7 @@ const FormatUrlType kFormatUrlOmitAll = kFormatUrlOmitUsernamePassword | kFormatUrlOmitHTTP | kFormatUrlOmitTrailingSlashOnBareHostname; // TODO(viettrungluu): We don't want non-POD globals; change this. -std::set<int> explicitly_allowed_ports; +std::multiset<int> explicitly_allowed_ports; GURL FilePathToFileURL(const FilePath& path) { // Produce a URL like "file:///C:/foo" for a regular file, or @@ -1496,12 +1496,7 @@ bool IsPortAllowedByOverride(int port) { if (explicitly_allowed_ports.empty()) return false; - std::set<int>::const_iterator it = - std::find(explicitly_allowed_ports.begin(), - explicitly_allowed_ports.end(), - port); - - return it != explicitly_allowed_ports.end(); + return explicitly_allowed_ports.count(port) > 0; } int SetNonBlocking(int fd) { @@ -1726,7 +1721,7 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) { if (allowed_ports.empty()) return; - std::set<int> ports; + std::multiset<int> ports; size_t last = 0; size_t size = allowed_ports.size(); // The comma delimiter. @@ -1752,6 +1747,18 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) { explicitly_allowed_ports = ports; } +ScopedPortException::ScopedPortException(int port) : port_(port) { + explicitly_allowed_ports.insert(port); +} + +ScopedPortException::~ScopedPortException() { + std::multiset<int>::iterator it = explicitly_allowed_ports.find(port_); + if (it != explicitly_allowed_ports.end()) + explicitly_allowed_ports.erase(it); + else + NOTREACHED(); +} + enum IPv6SupportStatus { IPV6_CANNOT_CREATE_SOCKETS, IPV6_CAN_CREATE_SOCKETS, |