diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 00:51:11 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 00:51:11 +0000 |
commit | 3912662a34a8d68749059d9a7d78fadaaea2dcc9 (patch) | |
tree | 74b11961f183f55fab28bd9c0cdb94acb7e2559e /net/http/http_stream_factory_impl.cc | |
parent | c97f7e663993fd1db91da6458ed2e7514dc19c6e (diff) | |
download | chromium_src-3912662a34a8d68749059d9a7d78fadaaea2dcc9.zip chromium_src-3912662a34a8d68749059d9a7d78fadaaea2dcc9.tar.gz chromium_src-3912662a34a8d68749059d9a7d78fadaaea2dcc9.tar.bz2 |
Support selection of SPDY on port other than 443
bug=93351
r=wtc
Review URL: http://codereview.chromium.org/7677025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream_factory_impl.cc')
-rw-r--r-- | net/http/http_stream_factory_impl.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc index ebb0ec7..8b7db82 100644 --- a/net/http/http_stream_factory_impl.cc +++ b/net/http/http_stream_factory_impl.cc @@ -18,12 +18,12 @@ namespace net { namespace { -GURL UpgradeUrlToHttps(const GURL& original_url) { +GURL UpgradeUrlToHttps(const GURL& original_url, int port) { GURL::Replacements replacements; // new_sheme and new_port need to be in scope here because GURL::Replacements // references the memory contained by them directly. const std::string new_scheme = "https"; - const std::string new_port = base::IntToString(443); + const std::string new_port = base::IntToString(port); replacements.SetSchemeStr(new_scheme); replacements.SetPortStr(new_port); return original_url.ReplaceComponents(replacements); @@ -150,11 +150,21 @@ bool HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( if (alternate.protocol != HttpAlternateProtocols::NPN_SPDY_2) return false; + // Some shared unix systems may have user home directories (like + // http://foo.com/~mike) which allow users to emit headers. This is a bad + // idea already, but with Alternate-Protocol, it provides the ability for a + // single user on a multi-user system to hijack the alternate protocol. + // These systems also enforce ports <1024 as restricted ports. So don't + // allow protocol upgrades to user-controllable ports. + const int kUnrestrictedPort = 1024; + if (alternate.port >= kUnrestrictedPort && origin.port() < kUnrestrictedPort) + return false; + origin.set_port(alternate.port); if (HttpStreamFactory::HasSpdyExclusion(origin)) return false; - *alternate_url = UpgradeUrlToHttps(original_url); + *alternate_url = UpgradeUrlToHttps(original_url, alternate.port); return true; } |