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 289601 1fd5bf9d2f18
parent 289600 c480e12985af
child 289602 849483c937b8
push id5210
push usercbook@mozilla.com
push date2015-10-21 14:38 +0000
treeherdermozilla-beta@1fd5bf9d2f18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb, sylvestre
bugs1215745
milestone42.0
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
@@ -977,25 +977,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)) {