Bug 1348278 - Limit speculative connections to http[s] only. r?mcmanus draft
authorNicholas Hurley <hurley@mozilla.com>
Fri, 28 Apr 2017 11:37:24 -0700
changeset 570395 c482eb943a2b080851aeb6175c9ae7cdd2ca7cc6
parent 569472 c0d35b1c5ab5fa9bb2f5661aa0454a1ce31b50e0
child 570396 65fe6134ee67071175c8e528450be68cc3b91ff9
push id56473
push userbmo:hurley@mozilla.com
push dateFri, 28 Apr 2017 20:01:47 +0000
reviewersmcmanus
bugs1348278
milestone55.0a1
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;
     }