Bug 1215745 - Safer implemetation of nsJarChannel::AsyncOpen2. r=ckerschb, a=sylvestre
authorJonas Sicking <jonas@sicking.cc>
Sun, 18 Oct 2015 20:20:29 -0700
changeset 296526 11dfa76155057efdd00c87673af09726ccad3aea
parent 296525 00900b1241c4f65c562290c0c901a0dc5cbfb711
child 296527 4c75c360726765393924489b381110cb8ee6de95
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb, sylvestre
bugs1215745
milestone43.0a2
Bug 1215745 - Safer implemetation of nsJarChannel::AsyncOpen2. r=ckerschb, a=sylvestre
modules/libjar/nsJARChannel.cpp
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -986,25 +986,20 @@ nsJARChannel::AsyncOpen(nsIStreamListene
 #endif
 
     return ContinueAsyncOpen();
 }
 
 NS_IMETHODIMP
 nsJARChannel::AsyncOpen2(nsIStreamListener *aListener)
 {
-  if (!mLoadInfo) {
-    MOZ_ASSERT(mLoadInfo, "can not enforce security without loadInfo");
-    return NS_ERROR_UNEXPECTED;
-  }
-  // setting the flag on the loadInfo indicates that the underlying
-  // channel will be openend using AsyncOpen2() and hence performs
-  // the necessary security checks.
-  mLoadInfo->SetEnforceSecurity(true);
-  return AsyncOpen(aListener, nullptr);
+  nsCOMPtr<nsIStreamListener> listener = aListener;
+  nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return AsyncOpen(listener, nullptr);
 }
 
 nsresult
 nsJARChannel::ContinueAsyncOpen()
 {
     LOG(("nsJARChannel::ContinueAsyncOpen [this=%x]\n", this));
     nsresult rv = LookupFile(true);
     if (NS_FAILED(rv)) {