Bug 1348278 - Limit speculative connections to http[s] only. r=mcmanus
authorNicholas Hurley <hurley@mozilla.com>
Fri, 28 Apr 2017 11:37:24 -0700
changeset 356036 ae9743c32bbb3090a909cbd38f12d538bc445fe0
parent 356035 6bdc48c4721afd1add3c08ba2bffa2a602942ae6
child 356037 dc2095a94b5e5d6932e386f5158a21604f35f915
push id41896
push userhurley@mozilla.com
push dateTue, 02 May 2017 16:27:35 +0000
treeherderautoland@dc2095a94b5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1348278
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1348278 - Limit speculative connections to http[s] only. r=mcmanus Some protocol handlers don't handle speculative connections too well (they crash). So, we limit to the most useful protocols. This patch brought to you by https://bugzilla.mozilla.org/show_bug.cgi?id=1348278#c21 MozReview-Commit-ID: 8dWGdVtalIS
netwerk/base/nsIOService.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1789,16 +1789,23 @@ IOServiceProxyCallback::OnProxyAvailable
 }
 
 nsresult
 nsIOService::SpeculativeConnectInternal(nsIURI *aURI,
                                         nsIPrincipal *aPrincipal,
                                         nsIInterfaceRequestor *aCallbacks,
                                         bool aAnonymous)
 {
+    bool isHTTP, isHTTPS;
+    if (!(NS_SUCCEEDED(aURI->SchemeIs("http", &isHTTP)) && isHTTP) &&
+        !(NS_SUCCEEDED(aURI->SchemeIs("https", &isHTTPS)) && isHTTPS)) {
+        // We don't speculatively connect to non-HTTP[S] URIs.
+        return NS_OK;
+    }
+
     if (IsNeckoChild()) {
         ipc::URIParams params;
         SerializeURI(aURI, params);
         gNeckoChild->SendSpeculativeConnect(params,
                                             IPC::Principal(aPrincipal),
                                             aAnonymous);
         return NS_OK;
     }