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

Unified Diff: net/base/net_util.cc

Issue 5519015: Explicitly whitelist the test server port. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 10 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 | « net/base/net_util.h ('k') | net/test/test_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 5426b6820511a246da0b8fd4964b7df54374783e..4f6e3613e2d235326328b5aadc96aba9b0e02cd5 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,
« no previous file with comments | « net/base/net_util.h ('k') | net/test/test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698