| File: | var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp |
| Warning: | line 531, column 7 Value stored to 'rv' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
| 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | #include "BackgroundUtils.h" |
| 8 | |
| 9 | #include "MainThreadUtils.h" |
| 10 | #include "mozilla/Assertions.h" |
| 11 | #include "mozilla/BasePrincipal.h" |
| 12 | #include "mozilla/ContentPrincipal.h" |
| 13 | #include "mozilla/NullPrincipal.h" |
| 14 | #include "mozilla/SystemPrincipal.h" |
| 15 | #include "mozilla/ipc/PBackgroundSharedTypes.h" |
| 16 | #include "mozilla/ipc/URIUtils.h" |
| 17 | #include "mozilla/net/CookieJarSettings.h" |
| 18 | #include "mozilla/net/InterceptionInfo.h" |
| 19 | #include "mozilla/net/NeckoChannelParams.h" |
| 20 | #include "ExpandedPrincipal.h" |
| 21 | #include "nsIScriptSecurityManager.h" |
| 22 | #include "nsIURI.h" |
| 23 | #include "nsNetUtil.h" |
| 24 | #include "mozilla/LoadInfo.h" |
| 25 | #include "nsContentUtils.h" |
| 26 | #include "nsString.h" |
| 27 | #include "nsTArray.h" |
| 28 | #include "mozilla/nsRedirectHistoryEntry.h" |
| 29 | #include "mozilla/dom/nsCSPUtils.h" |
| 30 | #include "mozilla/dom/nsCSPContext.h" |
| 31 | #include "mozilla/dom/BrowsingContext.h" |
| 32 | #include "mozilla/dom/CanonicalBrowsingContext.h" |
| 33 | #include "mozilla/dom/Document.h" |
| 34 | #include "mozilla/dom/WindowGlobalParent.h" |
| 35 | #include "mozilla/LoadInfo.h" |
| 36 | |
| 37 | using namespace mozilla::dom; |
| 38 | using namespace mozilla::net; |
| 39 | |
| 40 | namespace mozilla { |
| 41 | |
| 42 | namespace ipc { |
| 43 | |
| 44 | Result<nsCOMPtr<nsIPrincipal>, nsresult> PrincipalInfoToPrincipal( |
| 45 | const PrincipalInfo& aPrincipalInfo) { |
| 46 | MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipalInfo.type() != PrincipalInfo::T__None)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aPrincipalInfo.type() != PrincipalInfo::T__None))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipalInfo.type() != PrincipalInfo::T__None" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 46); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipalInfo.type() != PrincipalInfo::T__None" ")"); do { *((volatile int*)__null) = 46; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 47 | |
| 48 | nsCOMPtr<nsIPrincipal> principal; |
| 49 | nsresult rv; |
| 50 | |
| 51 | switch (aPrincipalInfo.type()) { |
| 52 | case PrincipalInfo::TSystemPrincipalInfo: { |
| 53 | principal = SystemPrincipal::Get(); |
| 54 | if (NS_WARN_IF(!principal)NS_warn_if_impl(!principal, "!principal", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 54)) { |
| 55 | return Err(NS_ERROR_NOT_INITIALIZED); |
| 56 | } |
| 57 | |
| 58 | return principal; |
| 59 | } |
| 60 | |
| 61 | case PrincipalInfo::TNullPrincipalInfo: { |
| 62 | const NullPrincipalInfo& info = aPrincipalInfo.get_NullPrincipalInfo(); |
| 63 | |
| 64 | nsCOMPtr<nsIURI> uri; |
| 65 | rv = NS_NewURI(getter_AddRefs(uri), info.spec()); |
| 66 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 66)) { |
| 67 | return Err(rv); |
| 68 | } |
| 69 | |
| 70 | if (!uri->SchemeIs(NS_NULLPRINCIPAL_SCHEME"moz-nullprincipal")) { |
| 71 | return Err(NS_ERROR_ILLEGAL_VALUE); |
| 72 | } |
| 73 | |
| 74 | principal = NullPrincipal::Create(info.attrs(), uri); |
| 75 | return principal; |
| 76 | } |
| 77 | |
| 78 | case PrincipalInfo::TContentPrincipalInfo: { |
| 79 | const ContentPrincipalInfo& info = |
| 80 | aPrincipalInfo.get_ContentPrincipalInfo(); |
| 81 | |
| 82 | nsCOMPtr<nsIURI> uri; |
| 83 | rv = NS_NewURI(getter_AddRefs(uri), info.spec()); |
| 84 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 84)) { |
| 85 | return Err(rv); |
| 86 | } |
| 87 | |
| 88 | nsCOMPtr<nsIURI> domain; |
| 89 | if (info.domain()) { |
| 90 | rv = NS_NewURI(getter_AddRefs(domain), *info.domain()); |
| 91 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 91)) { |
| 92 | return Err(rv); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | principal = |
| 97 | BasePrincipal::CreateContentPrincipal(uri, info.attrs(), domain); |
| 98 | if (NS_WARN_IF(!principal)NS_warn_if_impl(!principal, "!principal", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 98)) { |
| 99 | return Err(NS_ERROR_NULL_POINTER); |
| 100 | } |
| 101 | |
| 102 | // Origin must match what the_new_principal.getOrigin returns. |
| 103 | nsAutoCString originNoSuffix; |
| 104 | rv = principal->GetOriginNoSuffix(originNoSuffix); |
| 105 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 105)) { |
| 106 | return Err(rv); |
| 107 | } |
| 108 | |
| 109 | if (NS_WARN_IF(!info.originNoSuffix().Equals(originNoSuffix))NS_warn_if_impl(!info.originNoSuffix().Equals(originNoSuffix) , "!info.originNoSuffix().Equals(originNoSuffix)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 109)) { |
| 110 | return Err(NS_ERROR_FAILURE); |
| 111 | } |
| 112 | |
| 113 | if (!info.baseDomain().IsVoid()) { |
| 114 | nsAutoCString baseDomain; |
| 115 | rv = principal->GetBaseDomain(baseDomain); |
| 116 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 116)) { |
| 117 | return Err(rv); |
| 118 | } |
| 119 | |
| 120 | if (NS_WARN_IF(!info.baseDomain().Equals(baseDomain))NS_warn_if_impl(!info.baseDomain().Equals(baseDomain), "!info.baseDomain().Equals(baseDomain)" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 120)) { |
| 121 | return Err(NS_ERROR_FAILURE); |
| 122 | } |
| 123 | } |
| 124 | return principal; |
| 125 | } |
| 126 | |
| 127 | case PrincipalInfo::TExpandedPrincipalInfo: { |
| 128 | const ExpandedPrincipalInfo& info = |
| 129 | aPrincipalInfo.get_ExpandedPrincipalInfo(); |
| 130 | |
| 131 | nsTArray<nsCOMPtr<nsIPrincipal>> allowlist; |
| 132 | nsCOMPtr<nsIPrincipal> alPrincipal; |
| 133 | |
| 134 | for (uint32_t i = 0; i < info.allowlist().Length(); i++) { |
| 135 | auto principalOrErr = PrincipalInfoToPrincipal(info.allowlist()[i]); |
| 136 | if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 136)) { |
| 137 | nsresult ret = principalOrErr.unwrapErr(); |
| 138 | return Err(ret); |
| 139 | } |
| 140 | // append that principal to the allowlist |
| 141 | allowlist.AppendElement(principalOrErr.unwrap()); |
| 142 | } |
| 143 | |
| 144 | RefPtr<ExpandedPrincipal> expandedPrincipal = |
| 145 | ExpandedPrincipal::Create(allowlist, info.attrs()); |
| 146 | if (!expandedPrincipal) { |
| 147 | return Err(NS_ERROR_FAILURE); |
| 148 | } |
| 149 | |
| 150 | principal = expandedPrincipal; |
| 151 | return principal; |
| 152 | } |
| 153 | |
| 154 | default: |
| 155 | return Err(NS_ERROR_FAILURE); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | bool StorageKeysEqual(const PrincipalInfo& aLeft, const PrincipalInfo& aRight) { |
| 160 | MOZ_RELEASE_ASSERT(aLeft.type() == PrincipalInfo::TContentPrincipalInfo ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 161); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo" ")"); do { *((volatile int*)__null) = 161; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
| 161 | aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo)>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 161); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "aLeft.type() == PrincipalInfo::TContentPrincipalInfo || aLeft.type() == PrincipalInfo::TSystemPrincipalInfo" ")"); do { *((volatile int*)__null) = 161; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 162 | MOZ_RELEASE_ASSERT(aRight.type() == PrincipalInfo::TContentPrincipalInfo ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 163); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo" ")"); do { *((volatile int*)__null) = 163; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
| 163 | aRight.type() == PrincipalInfo::TSystemPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 163); AnnotateMozCrashReason("MOZ_RELEASE_ASSERT" "(" "aRight.type() == PrincipalInfo::TContentPrincipalInfo || aRight.type() == PrincipalInfo::TSystemPrincipalInfo" ")"); do { *((volatile int*)__null) = 163; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 164 | |
| 165 | if (aLeft.type() != aRight.type()) { |
| 166 | return false; |
| 167 | } |
| 168 | |
| 169 | if (aLeft.type() == PrincipalInfo::TContentPrincipalInfo) { |
| 170 | const ContentPrincipalInfo& leftContent = aLeft.get_ContentPrincipalInfo(); |
| 171 | const ContentPrincipalInfo& rightContent = |
| 172 | aRight.get_ContentPrincipalInfo(); |
| 173 | |
| 174 | return leftContent.attrs() == rightContent.attrs() && |
| 175 | leftContent.originNoSuffix() == rightContent.originNoSuffix(); |
| 176 | } |
| 177 | |
| 178 | // Storage keys for the System principal always equal. |
| 179 | return true; |
| 180 | } |
| 181 | |
| 182 | already_AddRefed<nsIContentSecurityPolicy> CSPInfoToCSP( |
| 183 | const CSPInfo& aCSPInfo, Document* aRequestingDoc, |
| 184 | nsresult* aOptionalResult) { |
| 185 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 185); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 185; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 186 | |
| 187 | nsresult stackResult; |
| 188 | nsresult& rv = aOptionalResult ? *aOptionalResult : stackResult; |
| 189 | |
| 190 | RefPtr<nsCSPContext> csp = new nsCSPContext(); |
| 191 | |
| 192 | if (aRequestingDoc) { |
| 193 | rv = csp->SetRequestContextWithDocument(aRequestingDoc); |
| 194 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 194)) { |
| 195 | return nullptr; |
| 196 | } |
| 197 | } else { |
| 198 | auto principalOrErr = |
| 199 | PrincipalInfoToPrincipal(aCSPInfo.requestPrincipalInfo()); |
| 200 | if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 200)) { |
| 201 | return nullptr; |
| 202 | } |
| 203 | |
| 204 | nsCOMPtr<nsIURI> selfURI; |
| 205 | if (!aCSPInfo.selfURISpec().IsEmpty()) { |
| 206 | rv = NS_NewURI(getter_AddRefs(selfURI), aCSPInfo.selfURISpec()); |
| 207 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 207)) { |
| 208 | return nullptr; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap(); |
| 213 | |
| 214 | rv = csp->SetRequestContextWithPrincipal( |
| 215 | principal, selfURI, aCSPInfo.referrer(), aCSPInfo.innerWindowID()); |
| 216 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 216)) { |
| 217 | return nullptr; |
| 218 | } |
| 219 | } |
| 220 | csp->SetSkipAllowInlineStyleCheck(aCSPInfo.skipAllowInlineStyleCheck()); |
| 221 | |
| 222 | for (uint32_t i = 0; i < aCSPInfo.policyInfos().Length(); i++) { |
| 223 | csp->AddIPCPolicy(aCSPInfo.policyInfos()[i]); |
| 224 | } |
| 225 | return csp.forget(); |
| 226 | } |
| 227 | |
| 228 | nsresult CSPToCSPInfo(nsIContentSecurityPolicy* aCSP, CSPInfo* aCSPInfo) { |
| 229 | MOZ_ASSERT(NS_IsMainThread())do { static_assert( mozilla::detail::AssertionConditionType< decltype(NS_IsMainThread())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(NS_IsMainThread()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("NS_IsMainThread()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 229); AnnotateMozCrashReason("MOZ_ASSERT" "(" "NS_IsMainThread()" ")"); do { *((volatile int*)__null) = 229; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 230 | MOZ_ASSERT(aCSP)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCSP)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(aCSP))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("aCSP", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCSP" ")"); do { *((volatile int*)__null) = 230; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); |
| 231 | MOZ_ASSERT(aCSPInfo)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aCSPInfo)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aCSPInfo))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aCSPInfo", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 231); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aCSPInfo" ")" ); do { *((volatile int*)__null) = 231; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 232 | |
| 233 | if (!aCSP || !aCSPInfo) { |
| 234 | return NS_ERROR_FAILURE; |
| 235 | } |
| 236 | |
| 237 | nsCOMPtr<nsIPrincipal> requestPrincipal = aCSP->GetRequestPrincipal(); |
| 238 | |
| 239 | PrincipalInfo requestingPrincipalInfo; |
| 240 | nsresult rv = |
| 241 | PrincipalToPrincipalInfo(requestPrincipal, &requestingPrincipalInfo); |
| 242 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 242)) { |
| 243 | return rv; |
| 244 | } |
| 245 | |
| 246 | nsCOMPtr<nsIURI> selfURI = aCSP->GetSelfURI(); |
| 247 | nsAutoCString selfURISpec; |
| 248 | if (selfURI) { |
| 249 | selfURI->GetSpec(selfURISpec); |
| 250 | } |
| 251 | |
| 252 | nsAutoCString referrer; |
| 253 | aCSP->GetReferrer(referrer); |
| 254 | |
| 255 | uint64_t windowID = aCSP->GetInnerWindowID(); |
| 256 | bool skipAllowInlineStyleCheck = aCSP->GetSkipAllowInlineStyleCheck(); |
| 257 | |
| 258 | RequireTrustedTypesForDirectiveState requireTrustedTypesForDirectiveState = |
| 259 | aCSP->GetRequireTrustedTypesForDirectiveState(); |
| 260 | |
| 261 | nsTArray<ContentSecurityPolicy> policies; |
| 262 | static_cast<nsCSPContext*>(aCSP)->SerializePolicies(policies); |
| 263 | |
| 264 | *aCSPInfo = CSPInfo(std::move(policies), requestingPrincipalInfo, selfURISpec, |
| 265 | referrer, windowID, requireTrustedTypesForDirectiveState, |
| 266 | skipAllowInlineStyleCheck); |
| 267 | return NS_OK; |
| 268 | } |
| 269 | |
| 270 | nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal, |
| 271 | PrincipalInfo* aPrincipalInfo, |
| 272 | bool aSkipBaseDomain) { |
| 273 | MOZ_ASSERT(aPrincipal)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipal)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipal))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipal", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 273); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")" ); do { *((volatile int*)__null) = 273; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 274 | MOZ_ASSERT(aPrincipalInfo)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPrincipalInfo)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPrincipalInfo))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPrincipalInfo" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 274); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipalInfo" ")"); do { *((volatile int*)__null) = 274; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 275 | |
| 276 | nsresult rv; |
| 277 | if (aPrincipal->GetIsNullPrincipal()) { |
| 278 | nsAutoCString spec; |
| 279 | rv = aPrincipal->GetAsciiSpec(spec); |
| 280 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 280)) { |
| 281 | return rv; |
| 282 | } |
| 283 | |
| 284 | *aPrincipalInfo = |
| 285 | NullPrincipalInfo(aPrincipal->OriginAttributesRef(), spec); |
| 286 | return NS_OK; |
| 287 | } |
| 288 | |
| 289 | if (aPrincipal->IsSystemPrincipal()) { |
| 290 | *aPrincipalInfo = SystemPrincipalInfo(); |
| 291 | return NS_OK; |
| 292 | } |
| 293 | |
| 294 | // might be an expanded principal |
| 295 | auto* basePrin = BasePrincipal::Cast(aPrincipal); |
| 296 | if (basePrin->Is<ExpandedPrincipal>()) { |
| 297 | auto* expanded = basePrin->As<ExpandedPrincipal>(); |
| 298 | |
| 299 | nsTArray<PrincipalInfo> allowlistInfo; |
| 300 | PrincipalInfo info; |
| 301 | |
| 302 | for (auto& prin : expanded->AllowList()) { |
| 303 | rv = PrincipalToPrincipalInfo(prin, &info, aSkipBaseDomain); |
| 304 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 304)) { |
| 305 | return rv; |
| 306 | } |
| 307 | // append that spec to the allowlist |
| 308 | allowlistInfo.AppendElement(info); |
| 309 | } |
| 310 | |
| 311 | *aPrincipalInfo = ExpandedPrincipalInfo(aPrincipal->OriginAttributesRef(), |
| 312 | std::move(allowlistInfo)); |
| 313 | return NS_OK; |
| 314 | } |
| 315 | |
| 316 | nsAutoCString spec; |
| 317 | rv = aPrincipal->GetAsciiSpec(spec); |
| 318 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 318)) { |
| 319 | return rv; |
| 320 | } |
| 321 | |
| 322 | nsCString originNoSuffix; |
| 323 | rv = aPrincipal->GetOriginNoSuffix(originNoSuffix); |
| 324 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 324)) { |
| 325 | return rv; |
| 326 | } |
| 327 | |
| 328 | nsCOMPtr<nsIURI> domainUri; |
| 329 | rv = aPrincipal->GetDomain(getter_AddRefs(domainUri)); |
| 330 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 330)) { |
| 331 | return rv; |
| 332 | } |
| 333 | |
| 334 | Maybe<nsCString> domain; |
| 335 | if (domainUri) { |
| 336 | domain.emplace(); |
| 337 | rv = domainUri->GetSpec(domain.ref()); |
| 338 | if (NS_WARN_IF(NS_FAILED(rv))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(rv )), 0))), "NS_FAILED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 338)) { |
| 339 | return rv; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | // This attribute is not crucial. |
| 344 | nsCString baseDomain; |
| 345 | if (aSkipBaseDomain) { |
| 346 | baseDomain.SetIsVoid(true); |
| 347 | } else { |
| 348 | if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))((bool)(__builtin_expect(!!(NS_FAILED_impl(aPrincipal->GetBaseDomain (baseDomain))), 0)))) { |
| 349 | // No warning here. Some principal URLs do not have a base-domain. |
| 350 | baseDomain.SetIsVoid(true); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | *aPrincipalInfo = |
| 355 | ContentPrincipalInfo(aPrincipal->OriginAttributesRef(), originNoSuffix, |
| 356 | spec, domain, baseDomain); |
| 357 | return NS_OK; |
| 358 | } |
| 359 | |
| 360 | bool IsPrincipalInfoPrivate(const PrincipalInfo& aPrincipalInfo) { |
| 361 | if (aPrincipalInfo.type() != ipc::PrincipalInfo::TContentPrincipalInfo) { |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | const ContentPrincipalInfo& info = aPrincipalInfo.get_ContentPrincipalInfo(); |
| 366 | return info.attrs().IsPrivateBrowsing(); |
| 367 | } |
| 368 | |
| 369 | already_AddRefed<nsIRedirectHistoryEntry> RHEntryInfoToRHEntry( |
| 370 | const RedirectHistoryEntryInfo& aRHEntryInfo) { |
| 371 | auto principalOrErr = PrincipalInfoToPrincipal(aRHEntryInfo.principalInfo()); |
| 372 | if (NS_WARN_IF(principalOrErr.isErr())NS_warn_if_impl(principalOrErr.isErr(), "principalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 372)) { |
| 373 | return nullptr; |
| 374 | } |
| 375 | |
| 376 | nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap(); |
| 377 | nsCOMPtr<nsIURI> referrerUri = DeserializeURI(aRHEntryInfo.referrerUri()); |
| 378 | |
| 379 | nsCOMPtr<nsIRedirectHistoryEntry> entry = new nsRedirectHistoryEntry( |
| 380 | principal, referrerUri, aRHEntryInfo.remoteAddress()); |
| 381 | |
| 382 | return entry.forget(); |
| 383 | } |
| 384 | |
| 385 | nsresult RHEntryToRHEntryInfo(nsIRedirectHistoryEntry* aRHEntry, |
| 386 | RedirectHistoryEntryInfo* aRHEntryInfo) { |
| 387 | MOZ_ASSERT(aRHEntry)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRHEntry)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aRHEntry))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aRHEntry", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 387); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntry" ")" ); do { *((volatile int*)__null) = 387; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 388 | MOZ_ASSERT(aRHEntryInfo)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aRHEntryInfo)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aRHEntryInfo))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aRHEntryInfo", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 388); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntryInfo" ")"); do { *((volatile int*)__null) = 388; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 389 | |
| 390 | nsresult rv; |
| 391 | aRHEntry->GetRemoteAddress(aRHEntryInfo->remoteAddress()); |
| 392 | |
| 393 | nsCOMPtr<nsIURI> referrerUri; |
| 394 | rv = aRHEntry->GetReferrerURI(getter_AddRefs(referrerUri)); |
| 395 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 395); return rv; } } while (false); |
| 396 | SerializeURI(referrerUri, aRHEntryInfo->referrerUri()); |
| 397 | |
| 398 | nsCOMPtr<nsIPrincipal> principal; |
| 399 | rv = aRHEntry->GetPrincipal(getter_AddRefs(principal)); |
| 400 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 400); return rv; } } while (false); |
| 401 | |
| 402 | return PrincipalToPrincipalInfo(principal, &aRHEntryInfo->principalInfo()); |
| 403 | } |
| 404 | |
| 405 | nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo, |
| 406 | LoadInfoArgs* outLoadInfoArgs) { |
| 407 | nsresult rv = NS_OK; |
| 408 | Maybe<PrincipalInfo> loadingPrincipalInfo; |
| 409 | if (nsIPrincipal* loadingPrin = aLoadInfo->GetLoadingPrincipal()) { |
| 410 | loadingPrincipalInfo.emplace(); |
| 411 | rv = PrincipalToPrincipalInfo(loadingPrin, loadingPrincipalInfo.ptr()); |
| 412 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 412); return rv; } } while (false); |
| 413 | } |
| 414 | |
| 415 | PrincipalInfo triggeringPrincipalInfo; |
| 416 | rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(), |
| 417 | &triggeringPrincipalInfo); |
| 418 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 418); return rv; } } while (false); |
| 419 | |
| 420 | Maybe<PrincipalInfo> principalToInheritInfo; |
| 421 | if (nsIPrincipal* principalToInherit = aLoadInfo->PrincipalToInherit()) { |
| 422 | principalToInheritInfo.emplace(); |
| 423 | rv = PrincipalToPrincipalInfo(principalToInherit, |
| 424 | principalToInheritInfo.ptr()); |
| 425 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 425); return rv; } } while (false); |
| 426 | } |
| 427 | |
| 428 | Maybe<PrincipalInfo> topLevelPrincipalInfo; |
| 429 | if (nsIPrincipal* topLevenPrin = aLoadInfo->GetTopLevelPrincipal()) { |
| 430 | topLevelPrincipalInfo.emplace(); |
| 431 | rv = PrincipalToPrincipalInfo(topLevenPrin, topLevelPrincipalInfo.ptr()); |
| 432 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 432); return rv; } } while (false); |
| 433 | } |
| 434 | |
| 435 | Maybe<URIParams> optionalResultPrincipalURI; |
| 436 | nsCOMPtr<nsIURI> resultPrincipalURI; |
| 437 | Unused << aLoadInfo->GetResultPrincipalURI( |
| 438 | getter_AddRefs(resultPrincipalURI)); |
| 439 | if (resultPrincipalURI) { |
| 440 | SerializeURI(resultPrincipalURI, optionalResultPrincipalURI); |
| 441 | } |
| 442 | |
| 443 | nsCString triggeringRemoteType; |
| 444 | rv = aLoadInfo->GetTriggeringRemoteType(triggeringRemoteType); |
| 445 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 445); return rv; } } while (false); |
| 446 | |
| 447 | nsTArray<RedirectHistoryEntryInfo> redirectChainIncludingInternalRedirects; |
| 448 | for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry : |
| 449 | aLoadInfo->RedirectChainIncludingInternalRedirects()) { |
| 450 | RedirectHistoryEntryInfo* entry = |
| 451 | redirectChainIncludingInternalRedirects.AppendElement(); |
| 452 | rv = RHEntryToRHEntryInfo(redirectEntry, entry); |
| 453 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 453); return rv; } } while (false); |
| 454 | } |
| 455 | |
| 456 | nsTArray<RedirectHistoryEntryInfo> redirectChain; |
| 457 | for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry : |
| 458 | aLoadInfo->RedirectChain()) { |
| 459 | RedirectHistoryEntryInfo* entry = redirectChain.AppendElement(); |
| 460 | rv = RHEntryToRHEntryInfo(redirectEntry, entry); |
| 461 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 461); return rv; } } while (false); |
| 462 | } |
| 463 | |
| 464 | Maybe<IPCClientInfo> ipcClientInfo; |
| 465 | const Maybe<ClientInfo>& clientInfo = aLoadInfo->GetClientInfo(); |
| 466 | if (clientInfo.isSome()) { |
| 467 | ipcClientInfo.emplace(clientInfo.ref().ToIPC()); |
| 468 | } |
| 469 | |
| 470 | Maybe<IPCClientInfo> ipcReservedClientInfo; |
| 471 | const Maybe<ClientInfo>& reservedClientInfo = |
| 472 | aLoadInfo->GetReservedClientInfo(); |
| 473 | if (reservedClientInfo.isSome()) { |
| 474 | ipcReservedClientInfo.emplace(reservedClientInfo.ref().ToIPC()); |
| 475 | } |
| 476 | |
| 477 | Maybe<IPCClientInfo> ipcInitialClientInfo; |
| 478 | const Maybe<ClientInfo>& initialClientInfo = |
| 479 | aLoadInfo->GetInitialClientInfo(); |
| 480 | if (initialClientInfo.isSome()) { |
| 481 | ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC()); |
| 482 | } |
| 483 | |
| 484 | Maybe<IPCServiceWorkerDescriptor> ipcController; |
| 485 | const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController(); |
| 486 | if (controller.isSome()) { |
| 487 | ipcController.emplace(controller.ref().ToIPC()); |
| 488 | } |
| 489 | |
| 490 | nsAutoString cspNonce; |
| 491 | Unused << NS_WARN_IF(NS_FAILED(aLoadInfo->GetCspNonce(cspNonce)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo ->GetCspNonce(cspNonce))), 0))), "NS_FAILED(aLoadInfo->GetCspNonce(cspNonce))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 491); |
| 492 | |
| 493 | nsAutoString integrityMetadata; |
| 494 | Unused << NS_WARN_IF(NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo ->GetIntegrityMetadata(integrityMetadata))), 0))), "NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 495) |
| 495 | NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(aLoadInfo ->GetIntegrityMetadata(integrityMetadata))), 0))), "NS_FAILED(aLoadInfo->GetIntegrityMetadata(integrityMetadata))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 495); |
| 496 | |
| 497 | nsCOMPtr<nsICookieJarSettings> cookieJarSettings; |
| 498 | rv = aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings)); |
| 499 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 499); return rv; } } while (false); |
| 500 | |
| 501 | CookieJarSettingsArgs cookieJarSettingsArgs; |
| 502 | static_cast<CookieJarSettings*>(cookieJarSettings.get()) |
| 503 | ->Serialize(cookieJarSettingsArgs); |
| 504 | |
| 505 | Maybe<CSPInfo> maybeCspToInheritInfo; |
| 506 | nsCOMPtr<nsIContentSecurityPolicy> cspToInherit = |
| 507 | aLoadInfo->GetCspToInherit(); |
| 508 | if (cspToInherit) { |
| 509 | CSPInfo cspToInheritInfo; |
| 510 | Unused << NS_WARN_IF(NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(CSPToCSPInfo (cspToInherit, &cspToInheritInfo))), 0))), "NS_FAILED(CSPToCSPInfo(cspToInherit, &cspToInheritInfo))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 511) |
| 511 | NS_FAILED(CSPToCSPInfo(cspToInherit, &cspToInheritInfo)))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(CSPToCSPInfo (cspToInherit, &cspToInheritInfo))), 0))), "NS_FAILED(CSPToCSPInfo(cspToInherit, &cspToInheritInfo))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 511); |
| 512 | maybeCspToInheritInfo.emplace(cspToInheritInfo); |
| 513 | } |
| 514 | |
| 515 | nsCOMPtr<nsIURI> unstrippedURI; |
| 516 | Unused << aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI)); |
| 517 | |
| 518 | Maybe<bool> isThirdPartyContextToTopWindow; |
| 519 | if (static_cast<LoadInfo*>(aLoadInfo) |
| 520 | ->HasIsThirdPartyContextToTopWindowSet()) { |
| 521 | isThirdPartyContextToTopWindow.emplace( |
| 522 | aLoadInfo->GetIsThirdPartyContextToTopWindow()); |
| 523 | } |
| 524 | |
| 525 | Maybe<InterceptionInfoArg> interceptionInfoArg; |
| 526 | nsIInterceptionInfo* interceptionInfo = aLoadInfo->InterceptionInfo(); |
| 527 | if (interceptionInfo) { |
| 528 | Maybe<PrincipalInfo> triggeringPrincipalInfo; |
| 529 | if (interceptionInfo->TriggeringPrincipal()) { |
| 530 | triggeringPrincipalInfo.emplace(); |
| 531 | rv = PrincipalToPrincipalInfo(interceptionInfo->TriggeringPrincipal(), |
Value stored to 'rv' is never read | |
| 532 | triggeringPrincipalInfo.ptr()); |
| 533 | } |
| 534 | |
| 535 | nsTArray<RedirectHistoryEntryInfo> redirectChain; |
| 536 | for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry : |
| 537 | interceptionInfo->RedirectChain()) { |
| 538 | RedirectHistoryEntryInfo* entry = redirectChain.AppendElement(); |
| 539 | rv = RHEntryToRHEntryInfo(redirectEntry, entry); |
| 540 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 540); return rv; } } while (false); |
| 541 | } |
| 542 | |
| 543 | interceptionInfoArg = Some(InterceptionInfoArg( |
| 544 | triggeringPrincipalInfo, interceptionInfo->ContentPolicyType(), |
| 545 | redirectChain, interceptionInfo->FromThirdParty())); |
| 546 | } |
| 547 | |
| 548 | Maybe<uint64_t> overriddenFingerprintingSettingsArg; |
| 549 | Maybe<RFPTarget> overriddenFingerprintingSettings = |
| 550 | aLoadInfo->GetOverriddenFingerprintingSettings(); |
| 551 | |
| 552 | if (overriddenFingerprintingSettings) { |
| 553 | overriddenFingerprintingSettingsArg = |
| 554 | Some(uint64_t(overriddenFingerprintingSettings.ref())); |
| 555 | } |
| 556 | |
| 557 | *outLoadInfoArgs = LoadInfoArgs( |
| 558 | loadingPrincipalInfo, triggeringPrincipalInfo, principalToInheritInfo, |
| 559 | topLevelPrincipalInfo, optionalResultPrincipalURI, triggeringRemoteType, |
| 560 | aLoadInfo->GetSandboxedNullPrincipalID(), aLoadInfo->GetSecurityFlags(), |
| 561 | aLoadInfo->GetSandboxFlags(), aLoadInfo->GetTriggeringSandboxFlags(), |
| 562 | aLoadInfo->GetTriggeringWindowId(), |
| 563 | aLoadInfo->GetTriggeringStorageAccess(), |
| 564 | aLoadInfo->InternalContentPolicyType(), |
| 565 | static_cast<uint32_t>(aLoadInfo->GetTainting()), |
| 566 | aLoadInfo->GetBlockAllMixedContent(), |
| 567 | aLoadInfo->GetUpgradeInsecureRequests(), |
| 568 | aLoadInfo->GetBrowserUpgradeInsecureRequests(), |
| 569 | aLoadInfo->GetBrowserDidUpgradeInsecureRequests(), |
| 570 | aLoadInfo->GetBrowserWouldUpgradeInsecureRequests(), |
| 571 | aLoadInfo->GetForceAllowDataURI(), |
| 572 | aLoadInfo->GetAllowInsecureRedirectToDataURI(), |
| 573 | aLoadInfo->GetSkipContentPolicyCheckForWebRequest(), |
| 574 | aLoadInfo->GetOriginalFrameSrcLoad(), |
| 575 | aLoadInfo->GetForceInheritPrincipalDropped(), |
| 576 | aLoadInfo->GetInnerWindowID(), aLoadInfo->GetBrowsingContextID(), |
| 577 | aLoadInfo->GetFrameBrowsingContextID(), |
| 578 | aLoadInfo->GetInitialSecurityCheckDone(), |
| 579 | aLoadInfo->GetIsInThirdPartyContext(), isThirdPartyContextToTopWindow, |
| 580 | aLoadInfo->GetIsOn3PCBExceptionList(), aLoadInfo->GetIsFormSubmission(), |
| 581 | aLoadInfo->GetIsGETRequest(), aLoadInfo->GetSendCSPViolationEvents(), |
| 582 | aLoadInfo->GetOriginAttributes(), redirectChainIncludingInternalRedirects, |
| 583 | redirectChain, aLoadInfo->GetHasInjectedCookieForCookieBannerHandling(), |
| 584 | aLoadInfo->GetSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(), |
| 585 | ipcClientInfo, ipcReservedClientInfo, ipcInitialClientInfo, ipcController, |
| 586 | aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(), |
| 587 | aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(), |
| 588 | aLoadInfo->GetServiceWorkerTaintingSynthesized(), |
| 589 | aLoadInfo->GetDocumentHasUserInteracted(), |
| 590 | aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(), |
| 591 | aLoadInfo->GetNeedForCheckingAntiTrackingHeuristic(), cspNonce, |
| 592 | integrityMetadata, aLoadInfo->GetSkipContentSniffing(), |
| 593 | aLoadInfo->GetHttpsOnlyStatus(), aLoadInfo->GetHstsStatus(), |
| 594 | aLoadInfo->GetHasValidUserGestureActivation(), |
| 595 | aLoadInfo->GetTextDirectiveUserActivation(), |
| 596 | aLoadInfo->GetAllowDeprecatedSystemRequests(), |
| 597 | aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(), |
| 598 | aLoadInfo->GetIsFromProcessingFrameAttributes(), |
| 599 | aLoadInfo->GetIsMediaRequest(), aLoadInfo->GetIsMediaInitialRequest(), |
| 600 | aLoadInfo->GetIsFromObjectOrEmbed(), cookieJarSettingsArgs, |
| 601 | aLoadInfo->GetRequestBlockingReason(), maybeCspToInheritInfo, |
| 602 | aLoadInfo->GetStoragePermission(), overriddenFingerprintingSettingsArg, |
| 603 | aLoadInfo->GetIsMetaRefresh(), aLoadInfo->GetLoadingEmbedderPolicy(), |
| 604 | aLoadInfo->GetIsOriginTrialCoepCredentiallessEnabledForTopLevel(), |
| 605 | unstrippedURI, interceptionInfoArg, aLoadInfo->GetIsNewWindowTarget()); |
| 606 | |
| 607 | return NS_OK; |
| 608 | } |
| 609 | |
| 610 | nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs, |
| 611 | const nsACString& aOriginRemoteType, |
| 612 | nsILoadInfo** outLoadInfo) { |
| 613 | return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr, |
| 614 | outLoadInfo); |
| 615 | } |
| 616 | nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs, |
| 617 | const nsACString& aOriginRemoteType, |
| 618 | nsINode* aCspToInheritLoadingContext, |
| 619 | nsILoadInfo** outLoadInfo) { |
| 620 | RefPtr<LoadInfo> loadInfo; |
| 621 | nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, |
| 622 | aCspToInheritLoadingContext, |
| 623 | getter_AddRefs(loadInfo)); |
| 624 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 624); return rv; } } while (false); |
| 625 | |
| 626 | loadInfo.forget(outLoadInfo); |
| 627 | return NS_OK; |
| 628 | } |
| 629 | |
| 630 | nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs, |
| 631 | const nsACString& aOriginRemoteType, |
| 632 | LoadInfo** outLoadInfo) { |
| 633 | return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr, |
| 634 | outLoadInfo); |
| 635 | } |
| 636 | nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs, |
| 637 | const nsACString& aOriginRemoteType, |
| 638 | nsINode* aCspToInheritLoadingContext, |
| 639 | LoadInfo** outLoadInfo) { |
| 640 | nsCOMPtr<nsIPrincipal> loadingPrincipal; |
| 641 | if (loadInfoArgs.requestingPrincipalInfo().isSome()) { |
| 642 | auto loadingPrincipalOrErr = |
| 643 | PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo().ref()); |
| 644 | if (NS_WARN_IF(loadingPrincipalOrErr.isErr())NS_warn_if_impl(loadingPrincipalOrErr.isErr(), "loadingPrincipalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 644)) { |
| 645 | return loadingPrincipalOrErr.unwrapErr(); |
| 646 | } |
| 647 | loadingPrincipal = loadingPrincipalOrErr.unwrap(); |
| 648 | } |
| 649 | |
| 650 | auto triggeringPrincipalOrErr = |
| 651 | PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo()); |
| 652 | if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 652)) { |
| 653 | return triggeringPrincipalOrErr.unwrapErr(); |
| 654 | } |
| 655 | nsCOMPtr<nsIPrincipal> triggeringPrincipal = |
| 656 | triggeringPrincipalOrErr.unwrap(); |
| 657 | |
| 658 | nsCOMPtr<nsIPrincipal> principalToInherit; |
| 659 | nsCOMPtr<nsIPrincipal> flattenedPrincipalToInherit; |
| 660 | if (loadInfoArgs.principalToInheritInfo().isSome()) { |
| 661 | auto principalToInheritOrErr = |
| 662 | PrincipalInfoToPrincipal(loadInfoArgs.principalToInheritInfo().ref()); |
| 663 | if (NS_WARN_IF(principalToInheritOrErr.isErr())NS_warn_if_impl(principalToInheritOrErr.isErr(), "principalToInheritOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 663)) { |
| 664 | return principalToInheritOrErr.unwrapErr(); |
| 665 | } |
| 666 | flattenedPrincipalToInherit = principalToInheritOrErr.unwrap(); |
| 667 | } |
| 668 | |
| 669 | if (XRE_IsContentProcess()) { |
| 670 | auto targetBrowsingContextId = loadInfoArgs.frameBrowsingContextID() |
| 671 | ? loadInfoArgs.frameBrowsingContextID() |
| 672 | : loadInfoArgs.browsingContextID(); |
| 673 | if (RefPtr<BrowsingContext> bc = |
| 674 | BrowsingContext::Get(targetBrowsingContextId)) { |
| 675 | auto [originalTriggeringPrincipal, originalPrincipalToInherit] = |
| 676 | bc->GetTriggeringAndInheritPrincipalsForCurrentLoad(); |
| 677 | |
| 678 | if (originalTriggeringPrincipal && |
| 679 | originalTriggeringPrincipal->Equals(triggeringPrincipal)) { |
| 680 | triggeringPrincipal = originalTriggeringPrincipal; |
| 681 | } |
| 682 | if (originalPrincipalToInherit && |
| 683 | (loadInfoArgs.securityFlags() & |
| 684 | nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL) && |
| 685 | originalPrincipalToInherit->Equals(flattenedPrincipalToInherit)) { |
| 686 | principalToInherit = originalPrincipalToInherit; |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | if (!principalToInherit && loadInfoArgs.principalToInheritInfo().isSome()) { |
| 691 | principalToInherit = flattenedPrincipalToInherit; |
| 692 | } |
| 693 | |
| 694 | nsCOMPtr<nsIPrincipal> topLevelPrincipal; |
| 695 | if (loadInfoArgs.topLevelPrincipalInfo().isSome()) { |
| 696 | auto topLevelPrincipalOrErr = |
| 697 | PrincipalInfoToPrincipal(loadInfoArgs.topLevelPrincipalInfo().ref()); |
| 698 | if (NS_WARN_IF(topLevelPrincipalOrErr.isErr())NS_warn_if_impl(topLevelPrincipalOrErr.isErr(), "topLevelPrincipalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 698)) { |
| 699 | return topLevelPrincipalOrErr.unwrapErr(); |
| 700 | } |
| 701 | topLevelPrincipal = topLevelPrincipalOrErr.unwrap(); |
| 702 | } |
| 703 | |
| 704 | nsCOMPtr<nsIURI> resultPrincipalURI; |
| 705 | if (loadInfoArgs.resultPrincipalURI().isSome()) { |
| 706 | resultPrincipalURI = DeserializeURI(loadInfoArgs.resultPrincipalURI()); |
| 707 | NS_ENSURE_TRUE(resultPrincipalURI, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(resultPrincipalURI)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "resultPrincipalURI" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 707); return NS_ERROR_UNEXPECTED; } } while (false); |
| 708 | } |
| 709 | |
| 710 | // If we received this message from a content process, reset |
| 711 | // triggeringRemoteType to the process which sent us the message. If the |
| 712 | // parent sent us the message, we trust it to provide the correct triggering |
| 713 | // remote type. |
| 714 | // |
| 715 | // This means that the triggering remote type will be reset if a LoadInfo is |
| 716 | // bounced through a content process, as the LoadInfo can no longer be |
| 717 | // validated to be coming from the originally specified remote type. |
| 718 | nsCString triggeringRemoteType = loadInfoArgs.triggeringRemoteType(); |
| 719 | if (aOriginRemoteType != NOT_REMOTE_TYPEVoidCString() && |
| 720 | aOriginRemoteType != triggeringRemoteType) { |
| 721 | triggeringRemoteType = aOriginRemoteType; |
| 722 | } |
| 723 | |
| 724 | RedirectHistoryArray redirectChainIncludingInternalRedirects; |
| 725 | for (const RedirectHistoryEntryInfo& entryInfo : |
| 726 | loadInfoArgs.redirectChainIncludingInternalRedirects()) { |
| 727 | nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry = |
| 728 | RHEntryInfoToRHEntry(entryInfo); |
| 729 | NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 729); return NS_ERROR_UNEXPECTED; } } while (false); |
| 730 | redirectChainIncludingInternalRedirects.AppendElement( |
| 731 | redirectHistoryEntry.forget()); |
| 732 | } |
| 733 | |
| 734 | RedirectHistoryArray redirectChain; |
| 735 | for (const RedirectHistoryEntryInfo& entryInfo : |
| 736 | loadInfoArgs.redirectChain()) { |
| 737 | nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry = |
| 738 | RHEntryInfoToRHEntry(entryInfo); |
| 739 | NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 739); return NS_ERROR_UNEXPECTED; } } while (false); |
| 740 | redirectChain.AppendElement(redirectHistoryEntry.forget()); |
| 741 | } |
| 742 | nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals; |
| 743 | nsTArray<uint64_t> ancestorBrowsingContextIDs; |
| 744 | if (XRE_IsParentProcess() && |
| 745 | (nsContentUtils::InternalContentPolicyTypeToExternal( |
| 746 | loadInfoArgs.contentPolicyType()) != |
| 747 | ExtContentPolicy::TYPE_DOCUMENT)) { |
| 748 | // Only fill out ancestor principals and browsing context IDs when we |
| 749 | // are deserializing LoadInfoArgs to be LoadInfo for a subresource |
| 750 | RefPtr<BrowsingContext> parentBC = |
| 751 | BrowsingContext::Get(loadInfoArgs.browsingContextID()); |
| 752 | if (parentBC) { |
| 753 | LoadInfo::ComputeAncestors(parentBC->Canonical(), ancestorPrincipals, |
| 754 | ancestorBrowsingContextIDs); |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | Maybe<ClientInfo> clientInfo; |
| 759 | if (loadInfoArgs.clientInfo().isSome()) { |
| 760 | clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref())); |
| 761 | } |
| 762 | |
| 763 | Maybe<ClientInfo> reservedClientInfo; |
| 764 | if (loadInfoArgs.reservedClientInfo().isSome()) { |
| 765 | reservedClientInfo.emplace( |
| 766 | ClientInfo(loadInfoArgs.reservedClientInfo().ref())); |
| 767 | } |
| 768 | |
| 769 | Maybe<ClientInfo> initialClientInfo; |
| 770 | if (loadInfoArgs.initialClientInfo().isSome()) { |
| 771 | initialClientInfo.emplace( |
| 772 | ClientInfo(loadInfoArgs.initialClientInfo().ref())); |
| 773 | } |
| 774 | |
| 775 | // We can have an initial client info or a reserved client info, but not both. |
| 776 | MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(reservedClientInfo.isNothing() || initialClientInfo. isNothing())>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(reservedClientInfo.isNothing() || initialClientInfo.isNothing()))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("reservedClientInfo.isNothing() || initialClientInfo.isNothing()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 777); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()" ")"); do { *((volatile int*)__null) = 777; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) |
| 777 | initialClientInfo.isNothing())do { static_assert( mozilla::detail::AssertionConditionType< decltype(reservedClientInfo.isNothing() || initialClientInfo. isNothing())>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(reservedClientInfo.isNothing() || initialClientInfo.isNothing()))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("reservedClientInfo.isNothing() || initialClientInfo.isNothing()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 777); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()" ")"); do { *((volatile int*)__null) = 777; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); |
| 778 | NS_ENSURE_TRUE(do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing( ) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 780); return NS_ERROR_UNEXPECTED; } } while (false) |
| 779 | reservedClientInfo.isNothing() || initialClientInfo.isNothing(),do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing( ) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 780); return NS_ERROR_UNEXPECTED; } } while (false) |
| 780 | NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(reservedClientInfo.isNothing( ) || initialClientInfo.isNothing())), 0))) { NS_DebugBreak(NS_DEBUG_WARNING , "NS_ENSURE_TRUE(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 780); return NS_ERROR_UNEXPECTED; } } while (false); |
| 781 | |
| 782 | Maybe<ServiceWorkerDescriptor> controller; |
| 783 | if (loadInfoArgs.controller().isSome()) { |
| 784 | controller.emplace( |
| 785 | ServiceWorkerDescriptor(loadInfoArgs.controller().ref())); |
| 786 | } |
| 787 | |
| 788 | nsCOMPtr<nsICookieJarSettings> cookieJarSettings; |
| 789 | CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(), |
| 790 | getter_AddRefs(cookieJarSettings)); |
| 791 | |
| 792 | Maybe<RFPTarget> overriddenFingerprintingSettings; |
| 793 | if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) { |
| 794 | overriddenFingerprintingSettings.emplace( |
| 795 | RFPTarget(loadInfoArgs.overriddenFingerprintingSettings().ref())); |
| 796 | } |
| 797 | |
| 798 | nsCOMPtr<nsIContentSecurityPolicy> cspToInherit; |
| 799 | Maybe<mozilla::ipc::CSPInfo> cspToInheritInfo = |
| 800 | loadInfoArgs.cspToInheritInfo(); |
| 801 | if (cspToInheritInfo.isSome()) { |
| 802 | nsCOMPtr<Document> doc = do_QueryInterface(aCspToInheritLoadingContext); |
| 803 | cspToInherit = CSPInfoToCSP(cspToInheritInfo.ref(), doc); |
| 804 | } |
| 805 | |
| 806 | // Restore the loadingContext for frames using the BrowsingContext's |
| 807 | // embedder element. Note that this only works if the embedder is |
| 808 | // same-process, so won't be fission compatible. |
| 809 | nsCOMPtr<nsINode> loadingContext; |
| 810 | RefPtr<BrowsingContext> frameBrowsingContext = |
| 811 | BrowsingContext::Get(loadInfoArgs.frameBrowsingContextID()); |
| 812 | if (frameBrowsingContext) { |
| 813 | loadingContext = frameBrowsingContext->GetEmbedderElement(); |
| 814 | } |
| 815 | |
| 816 | Maybe<bool> isThirdPartyContextToTopWindow; |
| 817 | if (loadInfoArgs.isThirdPartyContextToTopWindow().isSome()) { |
| 818 | isThirdPartyContextToTopWindow.emplace( |
| 819 | loadInfoArgs.isThirdPartyContextToTopWindow().ref()); |
| 820 | } |
| 821 | |
| 822 | nsCOMPtr<nsIInterceptionInfo> interceptionInfo; |
| 823 | if (loadInfoArgs.interceptionInfo().isSome()) { |
| 824 | const InterceptionInfoArg& interceptionInfoArg = |
| 825 | loadInfoArgs.interceptionInfo().ref(); |
| 826 | nsCOMPtr<nsIPrincipal> triggeringPrincipal; |
| 827 | if (interceptionInfoArg.triggeringPrincipalInfo().isSome()) { |
| 828 | auto triggeringPrincipalOrErr = PrincipalInfoToPrincipal( |
| 829 | interceptionInfoArg.triggeringPrincipalInfo().ref()); |
| 830 | if (NS_WARN_IF(triggeringPrincipalOrErr.isErr())NS_warn_if_impl(triggeringPrincipalOrErr.isErr(), "triggeringPrincipalOrErr.isErr()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 830)) { |
| 831 | return triggeringPrincipalOrErr.unwrapErr(); |
| 832 | } |
| 833 | triggeringPrincipal = triggeringPrincipalOrErr.unwrap(); |
| 834 | } |
| 835 | |
| 836 | RedirectHistoryArray redirectChain; |
| 837 | for (const RedirectHistoryEntryInfo& entryInfo : |
| 838 | interceptionInfoArg.redirectChain()) { |
| 839 | nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry = |
| 840 | RHEntryInfoToRHEntry(entryInfo); |
| 841 | NS_ENSURE_TRUE(redirectHistoryEntry, NS_ERROR_UNEXPECTED)do { if ((__builtin_expect(!!(!(redirectHistoryEntry)), 0))) { NS_DebugBreak(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "redirectHistoryEntry" ") failed", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 841); return NS_ERROR_UNEXPECTED; } } while (false); |
| 842 | redirectChain.AppendElement(redirectHistoryEntry.forget()); |
| 843 | } |
| 844 | |
| 845 | interceptionInfo = new InterceptionInfo( |
| 846 | triggeringPrincipal, interceptionInfoArg.contentPolicyType(), |
| 847 | redirectChain, interceptionInfoArg.fromThirdParty()); |
| 848 | } |
| 849 | |
| 850 | RefPtr<mozilla::net::LoadInfo> loadInfo = new mozilla::net::LoadInfo( |
| 851 | loadingPrincipal, triggeringPrincipal, principalToInherit, |
| 852 | topLevelPrincipal, resultPrincipalURI, cookieJarSettings, cspToInherit, |
| 853 | triggeringRemoteType, loadInfoArgs.sandboxedNullPrincipalID(), clientInfo, |
| 854 | reservedClientInfo, initialClientInfo, controller, |
| 855 | loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(), |
| 856 | loadInfoArgs.triggeringSandboxFlags(), loadInfoArgs.triggeringWindowId(), |
| 857 | loadInfoArgs.triggeringStorageAccess(), loadInfoArgs.contentPolicyType(), |
| 858 | static_cast<LoadTainting>(loadInfoArgs.tainting()), |
| 859 | loadInfoArgs.blockAllMixedContent(), |
| 860 | loadInfoArgs.upgradeInsecureRequests(), |
| 861 | loadInfoArgs.browserUpgradeInsecureRequests(), |
| 862 | loadInfoArgs.browserDidUpgradeInsecureRequests(), |
| 863 | loadInfoArgs.browserWouldUpgradeInsecureRequests(), |
| 864 | loadInfoArgs.forceAllowDataURI(), |
| 865 | loadInfoArgs.allowInsecureRedirectToDataURI(), |
| 866 | loadInfoArgs.skipContentPolicyCheckForWebRequest(), |
| 867 | loadInfoArgs.originalFrameSrcLoad(), |
| 868 | loadInfoArgs.forceInheritPrincipalDropped(), loadInfoArgs.innerWindowID(), |
| 869 | loadInfoArgs.browsingContextID(), loadInfoArgs.frameBrowsingContextID(), |
| 870 | loadInfoArgs.initialSecurityCheckDone(), |
| 871 | loadInfoArgs.isInThirdPartyContext(), isThirdPartyContextToTopWindow, |
| 872 | loadInfoArgs.isOn3PCBExceptionList(), loadInfoArgs.isFormSubmission(), |
| 873 | loadInfoArgs.isGETRequest(), loadInfoArgs.sendCSPViolationEvents(), |
| 874 | loadInfoArgs.originAttributes(), |
| 875 | std::move(redirectChainIncludingInternalRedirects), |
| 876 | std::move(redirectChain), std::move(ancestorPrincipals), |
| 877 | ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(), |
| 878 | loadInfoArgs.forcePreflight(), loadInfoArgs.isPreflight(), |
| 879 | loadInfoArgs.loadTriggeredFromExternal(), |
| 880 | loadInfoArgs.serviceWorkerTaintingSynthesized(), |
| 881 | loadInfoArgs.documentHasUserInteracted(), |
| 882 | loadInfoArgs.allowListFutureDocumentsCreatedFromThisRedirectChain(), |
| 883 | loadInfoArgs.needForCheckingAntiTrackingHeuristic(), |
| 884 | loadInfoArgs.cspNonce(), loadInfoArgs.integrityMetadata(), |
| 885 | loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(), |
| 886 | loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(), |
| 887 | loadInfoArgs.textDirectiveUserActivation(), |
| 888 | // This function is only called for moving LoadInfo across processes. |
| 889 | // Same-document navigation won't cross process boundaries. |
| 890 | /* aIsSameDocumentNavigation */ false, |
| 891 | loadInfoArgs.allowDeprecatedSystemRequests(), |
| 892 | loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(), |
| 893 | loadInfoArgs.storagePermission(), overriddenFingerprintingSettings, |
| 894 | loadInfoArgs.isMetaRefresh(), loadInfoArgs.requestBlockingReason(), |
| 895 | loadingContext, loadInfoArgs.loadingEmbedderPolicy(), |
| 896 | loadInfoArgs.originTrialCoepCredentiallessEnabledForTopLevel(), |
| 897 | loadInfoArgs.unstrippedURI(), interceptionInfo, |
| 898 | loadInfoArgs.hasInjectedCookieForCookieBannerHandling(), |
| 899 | loadInfoArgs.schemelessInput(), loadInfoArgs.httpsUpgradeTelemetry(), |
| 900 | loadInfoArgs.isNewWindowTarget()); |
| 901 | |
| 902 | if (loadInfoArgs.isFromProcessingFrameAttributes()) { |
| 903 | loadInfo->SetIsFromProcessingFrameAttributes(); |
| 904 | } |
| 905 | |
| 906 | if (loadInfoArgs.isMediaRequest()) { |
| 907 | loadInfo->SetIsMediaRequest(true); |
| 908 | |
| 909 | if (loadInfoArgs.isMediaInitialRequest()) { |
| 910 | loadInfo->SetIsMediaInitialRequest(true); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | if (loadInfoArgs.isFromObjectOrEmbed()) { |
| 915 | loadInfo->SetIsFromObjectOrEmbed(true); |
| 916 | } |
| 917 | |
| 918 | loadInfo.forget(outLoadInfo); |
| 919 | return NS_OK; |
| 920 | } |
| 921 | |
| 922 | void LoadInfoToParentLoadInfoForwarder( |
| 923 | nsILoadInfo* aLoadInfo, ParentLoadInfoForwarderArgs* aForwarderArgsOut) { |
| 924 | Maybe<IPCServiceWorkerDescriptor> ipcController; |
| 925 | Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController()); |
| 926 | if (controller.isSome()) { |
| 927 | ipcController.emplace(controller.ref().ToIPC()); |
| 928 | } |
| 929 | |
| 930 | uint32_t tainting = nsILoadInfo::TAINTING_BASIC; |
| 931 | Unused << aLoadInfo->GetTainting(&tainting); |
| 932 | |
| 933 | Maybe<CookieJarSettingsArgs> cookieJarSettingsArgs; |
| 934 | |
| 935 | nsCOMPtr<nsICookieJarSettings> cookieJarSettings; |
| 936 | nsresult rv = |
| 937 | aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings)); |
| 938 | CookieJarSettings* cs = |
| 939 | static_cast<CookieJarSettings*>(cookieJarSettings.get()); |
| 940 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings && cs->HasBeenChanged()) { |
| 941 | CookieJarSettingsArgs args; |
| 942 | cs->Serialize(args); |
| 943 | cookieJarSettingsArgs = Some(args); |
| 944 | } |
| 945 | |
| 946 | nsCOMPtr<nsIURI> unstrippedURI; |
| 947 | Unused << aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI)); |
| 948 | |
| 949 | Maybe<bool> isThirdPartyContextToTopWindow; |
| 950 | if (static_cast<LoadInfo*>(aLoadInfo) |
| 951 | ->HasIsThirdPartyContextToTopWindowSet()) { |
| 952 | isThirdPartyContextToTopWindow.emplace( |
| 953 | aLoadInfo->GetIsThirdPartyContextToTopWindow()); |
| 954 | } |
| 955 | |
| 956 | Maybe<uint64_t> overriddenFingerprintingSettingsArg; |
| 957 | Maybe<RFPTarget> overriddenFingerprintingSettings = |
| 958 | aLoadInfo->GetOverriddenFingerprintingSettings(); |
| 959 | |
| 960 | if (overriddenFingerprintingSettings) { |
| 961 | overriddenFingerprintingSettingsArg = |
| 962 | Some(uint64_t(overriddenFingerprintingSettings.ref())); |
| 963 | } |
| 964 | |
| 965 | *aForwarderArgsOut = ParentLoadInfoForwarderArgs( |
| 966 | aLoadInfo->GetAllowInsecureRedirectToDataURI(), ipcController, tainting, |
| 967 | aLoadInfo->GetSkipContentSniffing(), aLoadInfo->GetHttpsOnlyStatus(), |
| 968 | aLoadInfo->GetSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(), |
| 969 | aLoadInfo->GetHstsStatus(), aLoadInfo->GetHasValidUserGestureActivation(), |
| 970 | aLoadInfo->GetTextDirectiveUserActivation(), |
| 971 | aLoadInfo->GetAllowDeprecatedSystemRequests(), |
| 972 | aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(), |
| 973 | aLoadInfo->GetTriggeringSandboxFlags(), |
| 974 | aLoadInfo->GetTriggeringWindowId(), |
| 975 | aLoadInfo->GetTriggeringStorageAccess(), |
| 976 | aLoadInfo->GetServiceWorkerTaintingSynthesized(), |
| 977 | aLoadInfo->GetDocumentHasUserInteracted(), |
| 978 | aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(), |
| 979 | cookieJarSettingsArgs, aLoadInfo->GetContainerFeaturePolicyInfo(), |
| 980 | aLoadInfo->GetRequestBlockingReason(), aLoadInfo->GetStoragePermission(), |
| 981 | overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(), |
| 982 | isThirdPartyContextToTopWindow, aLoadInfo->GetIsInThirdPartyContext(), |
| 983 | aLoadInfo->GetIsOn3PCBExceptionList(), unstrippedURI); |
| 984 | } |
| 985 | |
| 986 | nsresult MergeParentLoadInfoForwarder( |
| 987 | ParentLoadInfoForwarderArgs const& aForwarderArgs, nsILoadInfo* aLoadInfo) { |
| 988 | nsresult rv; |
| 989 | |
| 990 | rv = aLoadInfo->SetAllowInsecureRedirectToDataURI( |
| 991 | aForwarderArgs.allowInsecureRedirectToDataURI()); |
| 992 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 992); return rv; } } while (false); |
| 993 | |
| 994 | aLoadInfo->ClearController(); |
| 995 | auto& controller = aForwarderArgs.controller(); |
| 996 | if (controller.isSome()) { |
| 997 | aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref())); |
| 998 | } |
| 999 | |
| 1000 | if (aForwarderArgs.serviceWorkerTaintingSynthesized()) { |
| 1001 | aLoadInfo->SynthesizeServiceWorkerTainting( |
| 1002 | static_cast<LoadTainting>(aForwarderArgs.tainting())); |
| 1003 | } else { |
| 1004 | aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting()); |
| 1005 | } |
| 1006 | rv = aLoadInfo->SetTextDirectiveUserActivation( |
| 1007 | aForwarderArgs.textDirectiveUserActivation()); |
| 1008 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1008); return rv; } } while (false); |
| 1009 | |
| 1010 | rv = aLoadInfo->SetSkipContentSniffing(aForwarderArgs.skipContentSniffing()); |
| 1011 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1011); return rv; } } while (false); |
| 1012 | |
| 1013 | rv = aLoadInfo->SetHttpsOnlyStatus(aForwarderArgs.httpsOnlyStatus()); |
| 1014 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1014); return rv; } } while (false); |
| 1015 | |
| 1016 | rv = aLoadInfo->SetSchemelessInput(aForwarderArgs.schemelessInput()); |
| 1017 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1017); return rv; } } while (false); |
| 1018 | |
| 1019 | rv = aLoadInfo->SetHttpsUpgradeTelemetry( |
| 1020 | aForwarderArgs.httpsUpgradeTelemetry()); |
| 1021 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1021); return rv; } } while (false); |
| 1022 | |
| 1023 | rv = aLoadInfo->SetHstsStatus(aForwarderArgs.hstsStatus()); |
| 1024 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1024); return rv; } } while (false); |
| 1025 | |
| 1026 | rv = aLoadInfo->SetTriggeringSandboxFlags( |
| 1027 | aForwarderArgs.triggeringSandboxFlags()); |
| 1028 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1028); return rv; } } while (false); |
| 1029 | |
| 1030 | rv = aLoadInfo->SetTriggeringWindowId(aForwarderArgs.triggeringWindowId()); |
| 1031 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1031); return rv; } } while (false); |
| 1032 | |
| 1033 | rv = aLoadInfo->SetTriggeringStorageAccess( |
| 1034 | aForwarderArgs.triggeringStorageAccess()); |
| 1035 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1035); return rv; } } while (false); |
| 1036 | |
| 1037 | rv = aLoadInfo->SetHasValidUserGestureActivation( |
| 1038 | aForwarderArgs.hasValidUserGestureActivation()); |
| 1039 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1039); return rv; } } while (false); |
| 1040 | |
| 1041 | rv = aLoadInfo->SetAllowDeprecatedSystemRequests( |
| 1042 | aForwarderArgs.allowDeprecatedSystemRequests()); |
| 1043 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1043); return rv; } } while (false); |
| 1044 | |
| 1045 | rv = aLoadInfo->SetIsInDevToolsContext(aForwarderArgs.isInDevToolsContext()); |
| 1046 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1046); return rv; } } while (false); |
| 1047 | |
| 1048 | rv = aLoadInfo->SetParserCreatedScript(aForwarderArgs.parserCreatedScript()); |
| 1049 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1049); return rv; } } while (false); |
| 1050 | |
| 1051 | MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetDocumentHasUserInteracted(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1052); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))" ")"); do { *((volatile int*)__null) = 1052; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ) |
| 1052 | aForwarderArgs.documentHasUserInteracted()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1052); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))" ")"); do { *((volatile int*)__null) = 1052; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ); |
| 1053 | MOZ_ALWAYS_SUCCEEDS(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain ( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1056); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" ")"); do { *((volatile int*)__null) = 1056; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ) |
| 1054 | aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain ( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1056); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" ")"); do { *((volatile int*)__null) = 1056; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ) |
| 1055 | aForwarderArgsdo { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain ( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1056); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" ")"); do { *((volatile int*)__null) = 1056; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ) |
| 1056 | .allowListFutureDocumentsCreatedFromThisRedirectChain()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain ( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1056); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))" ")"); do { *((volatile int*)__null) = 1056; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ); |
| 1057 | MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetRequestBlockingReason(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1058); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))" ")"); do { *((volatile int*)__null) = 1058; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ) |
| 1058 | aForwarderArgs.requestBlockingReason()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl (aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason ()))), 1)))), 1))) { } else { do { do { } while (false); MOZ_ReportCrash ("" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1058); AnnotateMozCrashReason("MOZ_CRASH(" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))" ")"); do { *((volatile int*)__null) = 1058; __attribute__((nomerge )) ::abort(); } while (false); } while (false); } } while (false ); |
| 1059 | |
| 1060 | const Maybe<CookieJarSettingsArgs>& cookieJarSettingsArgs = |
| 1061 | aForwarderArgs.cookieJarSettings(); |
| 1062 | if (cookieJarSettingsArgs.isSome()) { |
| 1063 | nsCOMPtr<nsICookieJarSettings> cookieJarSettings; |
| 1064 | nsresult rv = |
| 1065 | aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings)); |
| 1066 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings) { |
| 1067 | nsCOMPtr<nsICookieJarSettings> mergedCookieJarSettings; |
| 1068 | mergedCookieJarSettings = |
| 1069 | static_cast<CookieJarSettings*>(cookieJarSettings.get()) |
| 1070 | ->Merge(cookieJarSettingsArgs.ref()); |
| 1071 | aLoadInfo->SetCookieJarSettings(mergedCookieJarSettings); |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | rv = aLoadInfo->SetStoragePermission(aForwarderArgs.storagePermission()); |
| 1076 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1076); return rv; } } while (false); |
| 1077 | |
| 1078 | rv = aLoadInfo->SetIsMetaRefresh(aForwarderArgs.isMetaRefresh()); |
| 1079 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1079); return rv; } } while (false); |
| 1080 | |
| 1081 | const Maybe<uint64_t> overriddenFingerprintingSettings = |
| 1082 | aForwarderArgs.overriddenFingerprintingSettings(); |
| 1083 | if (overriddenFingerprintingSettings.isSome()) { |
| 1084 | aLoadInfo->SetOverriddenFingerprintingSettings( |
| 1085 | RFPTarget(overriddenFingerprintingSettings.ref())); |
| 1086 | } |
| 1087 | |
| 1088 | static_cast<LoadInfo*>(aLoadInfo)->ClearIsThirdPartyContextToTopWindow(); |
| 1089 | if (aForwarderArgs.isThirdPartyContextToTopWindow().isSome()) { |
| 1090 | rv = aLoadInfo->SetIsThirdPartyContextToTopWindow( |
| 1091 | aForwarderArgs.isThirdPartyContextToTopWindow().ref()); |
| 1092 | } |
| 1093 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1093); return rv; } } while (false); |
| 1094 | |
| 1095 | rv = aLoadInfo->SetIsInThirdPartyContext( |
| 1096 | aForwarderArgs.isInThirdPartyContext()); |
| 1097 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1097); return rv; } } while (false); |
| 1098 | |
| 1099 | rv = aLoadInfo->SetIsOn3PCBExceptionList( |
| 1100 | aForwarderArgs.isOn3PCBExceptionList()); |
| 1101 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1101); return rv; } } while (false); |
| 1102 | |
| 1103 | rv = aLoadInfo->SetUnstrippedURI(aForwarderArgs.unstrippedURI()); |
| 1104 | NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl (__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName (__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with " "result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t >(__rv), name ? " (" : "", name ? name : "", name ? ")" : "" ); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1104); return rv; } } while (false); |
| 1105 | |
| 1106 | if (aForwarderArgs.containerFeaturePolicyInfo()) { |
| 1107 | aLoadInfo->SetContainerFeaturePolicyInfo( |
| 1108 | *aForwarderArgs.containerFeaturePolicyInfo()); |
| 1109 | } |
| 1110 | |
| 1111 | return NS_OK; |
| 1112 | } |
| 1113 | |
| 1114 | void LoadInfoToChildLoadInfoForwarder( |
| 1115 | nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) { |
| 1116 | Maybe<IPCClientInfo> ipcReserved; |
| 1117 | Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo()); |
| 1118 | if (reserved.isSome()) { |
| 1119 | ipcReserved.emplace(reserved.ref().ToIPC()); |
| 1120 | } |
| 1121 | |
| 1122 | Maybe<IPCClientInfo> ipcInitial; |
| 1123 | Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo()); |
| 1124 | if (initial.isSome()) { |
| 1125 | ipcInitial.emplace(initial.ref().ToIPC()); |
| 1126 | } |
| 1127 | |
| 1128 | Maybe<IPCServiceWorkerDescriptor> ipcController; |
| 1129 | Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController()); |
| 1130 | if (controller.isSome()) { |
| 1131 | ipcController.emplace(controller.ref().ToIPC()); |
| 1132 | } |
| 1133 | |
| 1134 | *aForwarderArgsOut = |
| 1135 | ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController, |
| 1136 | aLoadInfo->GetRequestBlockingReason()); |
| 1137 | } |
| 1138 | |
| 1139 | nsresult MergeChildLoadInfoForwarder( |
| 1140 | const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) { |
| 1141 | Maybe<ClientInfo> reservedClientInfo; |
| 1142 | auto& ipcReserved = aForwarderArgs.reservedClientInfo(); |
| 1143 | if (ipcReserved.isSome()) { |
| 1144 | reservedClientInfo.emplace(ClientInfo(ipcReserved.ref())); |
| 1145 | } |
| 1146 | |
| 1147 | Maybe<ClientInfo> initialClientInfo; |
| 1148 | auto& ipcInitial = aForwarderArgs.initialClientInfo(); |
| 1149 | if (ipcInitial.isSome()) { |
| 1150 | initialClientInfo.emplace(ClientInfo(ipcInitial.ref())); |
| 1151 | } |
| 1152 | |
| 1153 | // There should only be at most one reserved or initial ClientInfo. |
| 1154 | if (NS_WARN_IF(reservedClientInfo.isSome() && initialClientInfo.isSome())NS_warn_if_impl(reservedClientInfo.isSome() && initialClientInfo .isSome(), "reservedClientInfo.isSome() && initialClientInfo.isSome()" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1154)) { |
| 1155 | return NS_ERROR_FAILURE; |
| 1156 | } |
| 1157 | |
| 1158 | // If we received no reserved or initial ClientInfo, then we must not |
| 1159 | // already have one set. There are no use cases where this should |
| 1160 | // happen and we don't have a way to clear the current value. |
| 1161 | if (NS_WARN_IF(reservedClientInfo.isNothing() &&NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo .isNothing() && (aLoadInfo->GetReservedClientInfo( ).isSome() || aLoadInfo->GetInitialClientInfo().isSome()), "reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1164) |
| 1162 | initialClientInfo.isNothing() &&NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo .isNothing() && (aLoadInfo->GetReservedClientInfo( ).isSome() || aLoadInfo->GetInitialClientInfo().isSome()), "reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1164) |
| 1163 | (aLoadInfo->GetReservedClientInfo().isSome() ||NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo .isNothing() && (aLoadInfo->GetReservedClientInfo( ).isSome() || aLoadInfo->GetInitialClientInfo().isSome()), "reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1164) |
| 1164 | aLoadInfo->GetInitialClientInfo().isSome()))NS_warn_if_impl(reservedClientInfo.isNothing() && initialClientInfo .isNothing() && (aLoadInfo->GetReservedClientInfo( ).isSome() || aLoadInfo->GetInitialClientInfo().isSome()), "reservedClientInfo.isNothing() && initialClientInfo.isNothing() && (aLoadInfo->GetReservedClientInfo().isSome() || aLoadInfo->GetInitialClientInfo().isSome())" , "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp" , 1164)) { |
| 1165 | return NS_ERROR_FAILURE; |
| 1166 | } |
| 1167 | |
| 1168 | if (reservedClientInfo.isSome()) { |
| 1169 | // We need to override here instead of simply set the value. This |
| 1170 | // allows us to change the reserved client. This is necessary when |
| 1171 | // the ClientChannelHelper created a new reserved client in the |
| 1172 | // child-side of the redirect. |
| 1173 | aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref()); |
| 1174 | } else if (initialClientInfo.isSome()) { |
| 1175 | aLoadInfo->SetInitialClientInfo(initialClientInfo.ref()); |
| 1176 | } |
| 1177 | |
| 1178 | aLoadInfo->ClearController(); |
| 1179 | auto& controller = aForwarderArgs.controller(); |
| 1180 | if (controller.isSome()) { |
| 1181 | aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref())); |
| 1182 | } |
| 1183 | |
| 1184 | uint32_t blockingReason = aForwarderArgs.requestBlockingReason(); |
| 1185 | if (blockingReason) { |
| 1186 | // We only want to override when non-null, so that any earlier set non-null |
| 1187 | // value is not reverted to 0. |
| 1188 | aLoadInfo->SetRequestBlockingReason(blockingReason); |
| 1189 | } |
| 1190 | |
| 1191 | return NS_OK; |
| 1192 | } |
| 1193 | |
| 1194 | } // namespace ipc |
| 1195 | } // namespace mozilla |