mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1336802 - Part 2: Updating the whole code base to make sure nsILoadInfo get null check. r=smaug
--HG-- extra : rebase_source : 22149fd540fd02119afe9fe5c9a815d01cf959c1
This commit is contained in:
parent
c44e5b4109
commit
756cf900c9
@ -9831,6 +9831,9 @@ nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel)
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
if (!loadInfo) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo->TriggeringPrincipal();
|
||||
|
||||
// Get the channel's load flags, and use them to generate nsIWebNavigation
|
||||
|
@ -2595,6 +2595,7 @@ nsObjectLoadingContent::OpenChannel()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (inherit) {
|
||||
nsCOMPtr<nsILoadInfo> loadinfo = chan->GetLoadInfo();
|
||||
NS_ENSURE_STATE(loadinfo);
|
||||
loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
|
||||
}
|
||||
|
||||
|
@ -2524,7 +2524,7 @@ nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
|
||||
} else {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
|
||||
if (loadInfo->GetEnforceSRI()) {
|
||||
if (loadInfo && loadInfo->GetEnforceSRI()) {
|
||||
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
|
||||
("nsScriptLoader::OnStreamComplete, required SRI not found"));
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
|
@ -349,7 +349,9 @@ FetchDriver::HttpFetch()
|
||||
AutoTArray<nsCString, 5> unsafeHeaders;
|
||||
mRequest->Headers()->GetUnsafeHeaders(unsafeHeaders);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
|
||||
loadInfo->SetCorsPreflightInfo(unsafeHeaders, false);
|
||||
if (loadInfo) {
|
||||
loadInfo->SetCorsPreflightInfo(unsafeHeaders, false);
|
||||
}
|
||||
}
|
||||
|
||||
rv = chan->AsyncOpen2(this);
|
||||
|
@ -2318,8 +2318,10 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
NS_ENSURE_STATE(loadInfo);
|
||||
loadInfo->SetPrincipalToInherit(NodePrincipal());
|
||||
|
||||
|
||||
mWyciwygChannel = do_QueryInterface(channel);
|
||||
|
||||
mWyciwygChannel->SetSecurityInfo(mSecurityInfo);
|
||||
|
@ -375,12 +375,16 @@ nsMixedContentBlocker::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
|
||||
nsCOMPtr<nsILoadInfo> newLoadInfo;
|
||||
rv = aNewChannel->GetLoadInfo(getter_AddRefs(newLoadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = nsMixedContentBlocker::MarkLoadInfoForPriming(newUri,
|
||||
requestingContext,
|
||||
newLoadInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (newLoadInfo) {
|
||||
rv = nsMixedContentBlocker::MarkLoadInfoForPriming(newUri,
|
||||
requestingContext,
|
||||
newLoadInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
decision = REJECT_REQUEST;
|
||||
newLoadInfo->ClearHSTSPriming();
|
||||
}
|
||||
} else {
|
||||
decision = REJECT_REQUEST;
|
||||
newLoadInfo->ClearHSTSPriming();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ public:
|
||||
NS_ENSURE_TRUE(underlyingChannel, NS_ERROR_UNEXPECTED);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = underlyingChannel->GetLoadInfo();
|
||||
|
||||
if (!CSPPermitsResponse(loadInfo)) {
|
||||
if (!loadInfo || !CSPPermitsResponse(loadInfo)) {
|
||||
mChannel->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1375,8 +1375,10 @@ public:
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(loadInfo);
|
||||
mContentPolicyType = loadInfo->InternalContentPolicyType();
|
||||
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
MOZ_ASSERT(httpChannel, "How come we don't have an HTTP channel?");
|
||||
|
||||
|
@ -867,6 +867,10 @@ XMLHttpRequestMainThread::IsCrossSiteCORSRequest() const
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
MOZ_ASSERT(loadInfo);
|
||||
|
||||
if (!loadInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return loadInfo->GetTainting() == LoadTainting::CORS;
|
||||
}
|
||||
|
||||
@ -1608,7 +1612,9 @@ XMLHttpRequestMainThread::SetOriginAttributes(const OriginAttributesDictionary&
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
MOZ_ASSERT(loadInfo);
|
||||
loadInfo->SetOriginAttributes(attrs);
|
||||
if (loadInfo) {
|
||||
loadInfo->SetOriginAttributes(attrs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -2107,7 +2113,10 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
MOZ_ASSERT(loadInfo);
|
||||
bool isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic;
|
||||
bool isCrossSite = false;
|
||||
if (loadInfo) {
|
||||
isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic;
|
||||
}
|
||||
|
||||
if (isCrossSite) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mResponseXML);
|
||||
@ -2502,8 +2511,10 @@ XMLHttpRequestMainThread::CreateChannel()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
rv = loadInfo->SetPrincipalToInherit(resultingDocumentPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (loadInfo) {
|
||||
rv = loadInfo->SetPrincipalToInherit(resultingDocumentPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2608,7 +2619,9 @@ XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
|
||||
// Not doing this for privileged system XHRs since those don't use CORS.
|
||||
if (!IsSystemXHR() && !mIsAnon && mFlagACwithCredentials) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
static_cast<net::LoadInfo*>(loadInfo.get())->SetIncludeCookiesSecFlag();
|
||||
if (loadInfo) {
|
||||
static_cast<net::LoadInfo*>(loadInfo.get())->SetIncludeCookiesSecFlag();
|
||||
}
|
||||
}
|
||||
|
||||
// Blocking gets are common enough out of XHR that we should mark
|
||||
@ -2669,8 +2682,10 @@ XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
|
||||
nsTArray<nsCString> CORSUnsafeHeaders;
|
||||
mAuthorRequestHeaders.GetCORSUnsafeHeaders(CORSUnsafeHeaders);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders,
|
||||
mFlagHadUploadListenersOnSend);
|
||||
if (loadInfo) {
|
||||
loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders,
|
||||
mFlagHadUploadListenersOnSend);
|
||||
}
|
||||
}
|
||||
|
||||
// Hook us up to listen to redirects and the like. Only do this very late
|
||||
|
@ -756,7 +756,9 @@ NewImageChannel(nsIChannel** aResult,
|
||||
attrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
|
||||
rv = loadInfo->SetOriginAttributes(attrs);
|
||||
if (loadInfo) {
|
||||
rv = loadInfo->SetOriginAttributes(attrs);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// either we are loading something inside a document, in which case
|
||||
@ -788,7 +790,9 @@ NewImageChannel(nsIChannel** aResult,
|
||||
attrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
|
||||
rv = loadInfo->SetOriginAttributes(attrs);
|
||||
if (loadInfo) {
|
||||
rv = loadInfo->SetOriginAttributes(attrs);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -942,7 +942,7 @@ SheetLoadData::OnStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
mSheet->GetIntegrity(sriMetadata);
|
||||
if (sriMetadata.IsEmpty()) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
if (loadInfo->GetEnforceSRI()) {
|
||||
if (loadInfo && loadInfo->GetEnforceSRI()) {
|
||||
LOG((" Load was blocked by SRI"));
|
||||
MOZ_LOG(gSriPRLog, mozilla::LogLevel::Debug,
|
||||
("css::Loader::OnStreamComplete, required SRI not found"));
|
||||
|
@ -1352,7 +1352,9 @@ Predictor::Prefetch(nsIURI *uri, nsIURI *referrer,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
||||
rv = loadInfo->SetOriginAttributes(originAttributes);
|
||||
if (loadInfo) {
|
||||
rv = loadInfo->SetOriginAttributes(originAttributes);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
PREDICTOR_LOG((" Set originAttributes into loadInfo failed rv=0x%X", rv));
|
||||
|
@ -1267,6 +1267,10 @@ NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport)
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
MOZ_RELEASE_ASSERT(loadInfo, "Origin tracking only works for channels created with a loadinfo");
|
||||
|
||||
if (!loadInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TYPE_DOCUMENT loads have a null LoadingPrincipal and can not be cross origin.
|
||||
if (!loadInfo->LoadingPrincipal()) {
|
||||
return false;
|
||||
|
@ -346,8 +346,9 @@ InterceptedChannelChrome::GetInternalContentPolicyType(nsContentPolicyType* aPol
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
nsresult rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aPolicyType = loadInfo->InternalContentPolicyType();
|
||||
if (loadInfo) {
|
||||
*aPolicyType = loadInfo->InternalContentPolicyType();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -515,7 +516,9 @@ InterceptedChannelContent::GetInternalContentPolicyType(nsContentPolicyType* aPo
|
||||
nsresult rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aPolicyType = loadInfo->InternalContentPolicyType();
|
||||
if (loadInfo) {
|
||||
*aPolicyType = loadInfo->InternalContentPolicyType();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -867,6 +867,10 @@ CheckUpgradeInsecureRequestsPreventsCORS(nsIPrincipal* aRequestingPrincipal,
|
||||
rv = aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
if (!loadInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// lets see if the loadInfo indicates that the request will
|
||||
// be upgraded before fetching any data from the netwerk.
|
||||
return loadInfo->GetUpgradeInsecureRequests();
|
||||
|
@ -127,7 +127,9 @@ WyciwygChannelParent::RecvInit(const URIParams& aURI,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
|
||||
rv = loadInfo->SetPrincipalToInherit(principalToInherit);
|
||||
if (loadInfo) {
|
||||
rv = loadInfo->SetPrincipalToInherit(principalToInherit);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
if (!SendCancelEarly(rv)) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
|
@ -133,7 +133,9 @@ nsUrlClassifierStreamUpdater::FetchUpdate(nsIURI *aUpdateUrl,
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
mozilla::OriginAttributes attrs;
|
||||
attrs.mFirstPartyDomain.AssignLiteral(NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN);
|
||||
loadInfo->SetOriginAttributes(attrs);
|
||||
if (loadInfo) {
|
||||
loadInfo->SetOriginAttributes(attrs);
|
||||
}
|
||||
|
||||
mBeganStream = false;
|
||||
|
||||
|
@ -202,10 +202,12 @@ nsPrefetchNode::OnStartRequest(nsIRequest *aRequest,
|
||||
// if the load is cross origin without CORS, or the CORS access is rejected,
|
||||
// always fire load event to avoid leaking site information.
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->GetLoadInfo();
|
||||
mShouldFireLoadEvent = loadInfo->GetTainting() == LoadTainting::Opaque ||
|
||||
(loadInfo->GetTainting() == LoadTainting::CORS &&
|
||||
(NS_FAILED(httpChannel->GetStatus(&rv)) ||
|
||||
NS_FAILED(rv)));
|
||||
if (loadInfo) {
|
||||
mShouldFireLoadEvent = loadInfo->GetTainting() == LoadTainting::Opaque ||
|
||||
(loadInfo->GetTainting() == LoadTainting::CORS &&
|
||||
(NS_FAILED(httpChannel->GetStatus(&rv)) ||
|
||||
NS_FAILED(rv)));
|
||||
}
|
||||
|
||||
// no need to prefetch http error page
|
||||
bool requestSucceeded;
|
||||
|
Loading…
Reference in New Issue
Block a user