Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp
Warning:line 527, column 7
Value stored to 'rv' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_ipc_glue0.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/glue -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/glue -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D HAVE_UINT64_T -D WEBRTC_MOZILLA_BUILD -D RTC_ENABLE_VP9 -D WEBRTC_POSIX -D WEBRTC_BUILD_LIBEVENT -D WEBRTC_LINUX -D WEBRTC_USE_PIPEWIRE -D WEBRTC_USE_X11 -D MOZ_CHILD_PROCESS_NAME="plugin-container" -D MOZ_CHILD_PROCESS_BUNDLENAME="None" -D MOZ_EME_PROCESS_NAME_BRANDED="Nightly Media Plugin Helper" -D MOZ_EME_PROCESS_BUNDLENAME="media-plugin-helper.app" -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/glue -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/glue -I /var/lib/jenkins/workspace/firefox-scan-build/caps -I /var/lib/jenkins/workspace/firefox-scan-build/dom/broadcastchannel -I /var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB -I /var/lib/jenkins/workspace/firefox-scan-build/dom/storage -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/base -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/libwebrtc -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/libwebrtc/third_party/abseil-cpp -I /var/lib/jenkins/workspace/firefox-scan-build/tools/fuzzing/ipc -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/build -I /var/lib/jenkins/workspace/firefox-scan-build/dom/ipc -I /var/lib/jenkins/workspace/firefox-scan-build/toolkit/crashreporter -I /var/lib/jenkins/workspace/firefox-scan-build/toolkit/xre -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/base -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/threads -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-07-21-021012-413605-1 -x c++ Unified_cpp_ipc_glue0.cpp
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
37using namespace mozilla::dom;
38using namespace mozilla::net;
39
40namespace mozilla {
41
42namespace ipc {
43
44Result<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
159bool 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
182already_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
228nsresult 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 nsTArray<ContentSecurityPolicy> policies;
259 static_cast<nsCSPContext*>(aCSP)->SerializePolicies(policies);
260
261 *aCSPInfo = CSPInfo(std::move(policies), requestingPrincipalInfo, selfURISpec,
262 referrer, windowID, skipAllowInlineStyleCheck);
263 return NS_OK;
264}
265
266nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
267 PrincipalInfo* aPrincipalInfo,
268 bool aSkipBaseDomain) {
269 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"
, 269); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipal" ")"
); do { *((volatile int*)__null) = 269; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
270 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"
, 270); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPrincipalInfo"
")"); do { *((volatile int*)__null) = 270; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
271
272 nsresult rv;
273 if (aPrincipal->GetIsNullPrincipal()) {
274 nsAutoCString spec;
275 rv = aPrincipal->GetAsciiSpec(spec);
276 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"
, 276)
) {
277 return rv;
278 }
279
280 *aPrincipalInfo =
281 NullPrincipalInfo(aPrincipal->OriginAttributesRef(), spec);
282 return NS_OK;
283 }
284
285 if (aPrincipal->IsSystemPrincipal()) {
286 *aPrincipalInfo = SystemPrincipalInfo();
287 return NS_OK;
288 }
289
290 // might be an expanded principal
291 auto* basePrin = BasePrincipal::Cast(aPrincipal);
292 if (basePrin->Is<ExpandedPrincipal>()) {
293 auto* expanded = basePrin->As<ExpandedPrincipal>();
294
295 nsTArray<PrincipalInfo> allowlistInfo;
296 PrincipalInfo info;
297
298 for (auto& prin : expanded->AllowList()) {
299 rv = PrincipalToPrincipalInfo(prin, &info, aSkipBaseDomain);
300 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"
, 300)
) {
301 return rv;
302 }
303 // append that spec to the allowlist
304 allowlistInfo.AppendElement(info);
305 }
306
307 *aPrincipalInfo = ExpandedPrincipalInfo(aPrincipal->OriginAttributesRef(),
308 std::move(allowlistInfo));
309 return NS_OK;
310 }
311
312 nsAutoCString spec;
313 rv = aPrincipal->GetAsciiSpec(spec);
314 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"
, 314)
) {
315 return rv;
316 }
317
318 nsCString originNoSuffix;
319 rv = aPrincipal->GetOriginNoSuffix(originNoSuffix);
320 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"
, 320)
) {
321 return rv;
322 }
323
324 nsCOMPtr<nsIURI> domainUri;
325 rv = aPrincipal->GetDomain(getter_AddRefs(domainUri));
326 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"
, 326)
) {
327 return rv;
328 }
329
330 Maybe<nsCString> domain;
331 if (domainUri) {
332 domain.emplace();
333 rv = domainUri->GetSpec(domain.ref());
334 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"
, 334)
) {
335 return rv;
336 }
337 }
338
339 // This attribute is not crucial.
340 nsCString baseDomain;
341 if (aSkipBaseDomain) {
342 baseDomain.SetIsVoid(true);
343 } else {
344 if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))((bool)(__builtin_expect(!!(NS_FAILED_impl(aPrincipal->GetBaseDomain
(baseDomain))), 0)))
) {
345 // No warning here. Some principal URLs do not have a base-domain.
346 baseDomain.SetIsVoid(true);
347 }
348 }
349
350 *aPrincipalInfo =
351 ContentPrincipalInfo(aPrincipal->OriginAttributesRef(), originNoSuffix,
352 spec, domain, baseDomain);
353 return NS_OK;
354}
355
356bool IsPrincipalInfoPrivate(const PrincipalInfo& aPrincipalInfo) {
357 if (aPrincipalInfo.type() != ipc::PrincipalInfo::TContentPrincipalInfo) {
358 return false;
359 }
360
361 const ContentPrincipalInfo& info = aPrincipalInfo.get_ContentPrincipalInfo();
362 return info.attrs().IsPrivateBrowsing();
363}
364
365already_AddRefed<nsIRedirectHistoryEntry> RHEntryInfoToRHEntry(
366 const RedirectHistoryEntryInfo& aRHEntryInfo) {
367 auto principalOrErr = PrincipalInfoToPrincipal(aRHEntryInfo.principalInfo());
368 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"
, 368)
) {
369 return nullptr;
370 }
371
372 nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap();
373 nsCOMPtr<nsIURI> referrerUri = DeserializeURI(aRHEntryInfo.referrerUri());
374
375 nsCOMPtr<nsIRedirectHistoryEntry> entry = new nsRedirectHistoryEntry(
376 principal, referrerUri, aRHEntryInfo.remoteAddress());
377
378 return entry.forget();
379}
380
381nsresult RHEntryToRHEntryInfo(nsIRedirectHistoryEntry* aRHEntry,
382 RedirectHistoryEntryInfo* aRHEntryInfo) {
383 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"
, 383); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntry" ")"
); do { *((volatile int*)__null) = 383; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
384 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"
, 384); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aRHEntryInfo"
")"); do { *((volatile int*)__null) = 384; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
385
386 nsresult rv;
387 aRHEntry->GetRemoteAddress(aRHEntryInfo->remoteAddress());
388
389 nsCOMPtr<nsIURI> referrerUri;
390 rv = aRHEntry->GetReferrerURI(getter_AddRefs(referrerUri));
391 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"
, 391); return rv; } } while (false)
;
392 SerializeURI(referrerUri, aRHEntryInfo->referrerUri());
393
394 nsCOMPtr<nsIPrincipal> principal;
395 rv = aRHEntry->GetPrincipal(getter_AddRefs(principal));
396 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"
, 396); return rv; } } while (false)
;
397
398 return PrincipalToPrincipalInfo(principal, &aRHEntryInfo->principalInfo());
399}
400
401nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
402 LoadInfoArgs* outLoadInfoArgs) {
403 nsresult rv = NS_OK;
404 Maybe<PrincipalInfo> loadingPrincipalInfo;
405 if (nsIPrincipal* loadingPrin = aLoadInfo->GetLoadingPrincipal()) {
406 loadingPrincipalInfo.emplace();
407 rv = PrincipalToPrincipalInfo(loadingPrin, loadingPrincipalInfo.ptr());
408 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"
, 408); return rv; } } while (false)
;
409 }
410
411 PrincipalInfo triggeringPrincipalInfo;
412 rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
413 &triggeringPrincipalInfo);
414 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"
, 414); return rv; } } while (false)
;
415
416 Maybe<PrincipalInfo> principalToInheritInfo;
417 if (nsIPrincipal* principalToInherit = aLoadInfo->PrincipalToInherit()) {
418 principalToInheritInfo.emplace();
419 rv = PrincipalToPrincipalInfo(principalToInherit,
420 principalToInheritInfo.ptr());
421 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"
, 421); return rv; } } while (false)
;
422 }
423
424 Maybe<PrincipalInfo> topLevelPrincipalInfo;
425 if (nsIPrincipal* topLevenPrin = aLoadInfo->GetTopLevelPrincipal()) {
426 topLevelPrincipalInfo.emplace();
427 rv = PrincipalToPrincipalInfo(topLevenPrin, topLevelPrincipalInfo.ptr());
428 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"
, 428); return rv; } } while (false)
;
429 }
430
431 Maybe<URIParams> optionalResultPrincipalURI;
432 nsCOMPtr<nsIURI> resultPrincipalURI;
433 Unused << aLoadInfo->GetResultPrincipalURI(
434 getter_AddRefs(resultPrincipalURI));
435 if (resultPrincipalURI) {
436 SerializeURI(resultPrincipalURI, optionalResultPrincipalURI);
437 }
438
439 nsCString triggeringRemoteType;
440 rv = aLoadInfo->GetTriggeringRemoteType(triggeringRemoteType);
441 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"
, 441); return rv; } } while (false)
;
442
443 nsTArray<RedirectHistoryEntryInfo> redirectChainIncludingInternalRedirects;
444 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
445 aLoadInfo->RedirectChainIncludingInternalRedirects()) {
446 RedirectHistoryEntryInfo* entry =
447 redirectChainIncludingInternalRedirects.AppendElement();
448 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
449 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"
, 449); return rv; } } while (false)
;
450 }
451
452 nsTArray<RedirectHistoryEntryInfo> redirectChain;
453 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
454 aLoadInfo->RedirectChain()) {
455 RedirectHistoryEntryInfo* entry = redirectChain.AppendElement();
456 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
457 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"
, 457); return rv; } } while (false)
;
458 }
459
460 Maybe<IPCClientInfo> ipcClientInfo;
461 const Maybe<ClientInfo>& clientInfo = aLoadInfo->GetClientInfo();
462 if (clientInfo.isSome()) {
463 ipcClientInfo.emplace(clientInfo.ref().ToIPC());
464 }
465
466 Maybe<IPCClientInfo> ipcReservedClientInfo;
467 const Maybe<ClientInfo>& reservedClientInfo =
468 aLoadInfo->GetReservedClientInfo();
469 if (reservedClientInfo.isSome()) {
470 ipcReservedClientInfo.emplace(reservedClientInfo.ref().ToIPC());
471 }
472
473 Maybe<IPCClientInfo> ipcInitialClientInfo;
474 const Maybe<ClientInfo>& initialClientInfo =
475 aLoadInfo->GetInitialClientInfo();
476 if (initialClientInfo.isSome()) {
477 ipcInitialClientInfo.emplace(initialClientInfo.ref().ToIPC());
478 }
479
480 Maybe<IPCServiceWorkerDescriptor> ipcController;
481 const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController();
482 if (controller.isSome()) {
483 ipcController.emplace(controller.ref().ToIPC());
484 }
485
486 nsAutoString cspNonce;
487 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"
, 487)
;
488
489 nsAutoString integrityMetadata;
490 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"
, 491)
491 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"
, 491)
;
492
493 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
494 rv = aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
495 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"
, 495); return rv; } } while (false)
;
496
497 CookieJarSettingsArgs cookieJarSettingsArgs;
498 static_cast<CookieJarSettings*>(cookieJarSettings.get())
499 ->Serialize(cookieJarSettingsArgs);
500
501 Maybe<CSPInfo> maybeCspToInheritInfo;
502 nsCOMPtr<nsIContentSecurityPolicy> cspToInherit =
503 aLoadInfo->GetCspToInherit();
504 if (cspToInherit) {
505 CSPInfo cspToInheritInfo;
506 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"
, 507)
507 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"
, 507)
;
508 maybeCspToInheritInfo.emplace(cspToInheritInfo);
509 }
510
511 nsCOMPtr<nsIURI> unstrippedURI;
512 Unused << aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
513
514 Maybe<bool> isThirdPartyContextToTopWindow;
515 if (static_cast<LoadInfo*>(aLoadInfo)
516 ->HasIsThirdPartyContextToTopWindowSet()) {
517 isThirdPartyContextToTopWindow.emplace(
518 aLoadInfo->GetIsThirdPartyContextToTopWindow());
519 }
520
521 Maybe<InterceptionInfoArg> interceptionInfoArg;
522 nsIInterceptionInfo* interceptionInfo = aLoadInfo->InterceptionInfo();
523 if (interceptionInfo) {
524 Maybe<PrincipalInfo> triggeringPrincipalInfo;
525 if (interceptionInfo->TriggeringPrincipal()) {
526 triggeringPrincipalInfo.emplace();
527 rv = PrincipalToPrincipalInfo(interceptionInfo->TriggeringPrincipal(),
Value stored to 'rv' is never read
528 triggeringPrincipalInfo.ptr());
529 }
530
531 nsTArray<RedirectHistoryEntryInfo> redirectChain;
532 for (const nsCOMPtr<nsIRedirectHistoryEntry>& redirectEntry :
533 interceptionInfo->RedirectChain()) {
534 RedirectHistoryEntryInfo* entry = redirectChain.AppendElement();
535 rv = RHEntryToRHEntryInfo(redirectEntry, entry);
536 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"
, 536); return rv; } } while (false)
;
537 }
538
539 interceptionInfoArg = Some(InterceptionInfoArg(
540 triggeringPrincipalInfo, interceptionInfo->ContentPolicyType(),
541 redirectChain, interceptionInfo->FromThirdParty()));
542 }
543
544 Maybe<uint64_t> overriddenFingerprintingSettingsArg;
545 Maybe<RFPTarget> overriddenFingerprintingSettings =
546 aLoadInfo->GetOverriddenFingerprintingSettings();
547
548 if (overriddenFingerprintingSettings) {
549 overriddenFingerprintingSettingsArg =
550 Some(uint64_t(overriddenFingerprintingSettings.ref()));
551 }
552
553 *outLoadInfoArgs = LoadInfoArgs(
554 loadingPrincipalInfo, triggeringPrincipalInfo, principalToInheritInfo,
555 topLevelPrincipalInfo, optionalResultPrincipalURI, triggeringRemoteType,
556 aLoadInfo->GetSandboxedNullPrincipalID(), aLoadInfo->GetSecurityFlags(),
557 aLoadInfo->GetSandboxFlags(), aLoadInfo->GetTriggeringSandboxFlags(),
558 aLoadInfo->GetTriggeringWindowId(),
559 aLoadInfo->GetTriggeringStorageAccess(),
560 aLoadInfo->InternalContentPolicyType(),
561 static_cast<uint32_t>(aLoadInfo->GetTainting()),
562 aLoadInfo->GetBlockAllMixedContent(),
563 aLoadInfo->GetUpgradeInsecureRequests(),
564 aLoadInfo->GetBrowserUpgradeInsecureRequests(),
565 aLoadInfo->GetBrowserDidUpgradeInsecureRequests(),
566 aLoadInfo->GetBrowserWouldUpgradeInsecureRequests(),
567 aLoadInfo->GetForceAllowDataURI(),
568 aLoadInfo->GetAllowInsecureRedirectToDataURI(),
569 aLoadInfo->GetSkipContentPolicyCheckForWebRequest(),
570 aLoadInfo->GetOriginalFrameSrcLoad(),
571 aLoadInfo->GetForceInheritPrincipalDropped(),
572 aLoadInfo->GetInnerWindowID(), aLoadInfo->GetBrowsingContextID(),
573 aLoadInfo->GetFrameBrowsingContextID(),
574 aLoadInfo->GetInitialSecurityCheckDone(),
575 aLoadInfo->GetIsInThirdPartyContext(), isThirdPartyContextToTopWindow,
576 aLoadInfo->GetIsFormSubmission(), aLoadInfo->GetSendCSPViolationEvents(),
577 aLoadInfo->GetOriginAttributes(), redirectChainIncludingInternalRedirects,
578 redirectChain, aLoadInfo->GetHasInjectedCookieForCookieBannerHandling(),
579 aLoadInfo->GetWasSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(),
580 ipcClientInfo, ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
581 aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(),
582 aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(),
583 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
584 aLoadInfo->GetDocumentHasUserInteracted(),
585 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
586 aLoadInfo->GetNeedForCheckingAntiTrackingHeuristic(), cspNonce,
587 integrityMetadata, aLoadInfo->GetSkipContentSniffing(),
588 aLoadInfo->GetHttpsOnlyStatus(), aLoadInfo->GetHstsStatus(),
589 aLoadInfo->GetHasValidUserGestureActivation(),
590 aLoadInfo->GetTextDirectiveUserActivation(),
591 aLoadInfo->GetAllowDeprecatedSystemRequests(),
592 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
593 aLoadInfo->GetIsFromProcessingFrameAttributes(),
594 aLoadInfo->GetIsMediaRequest(), aLoadInfo->GetIsMediaInitialRequest(),
595 aLoadInfo->GetIsFromObjectOrEmbed(), cookieJarSettingsArgs,
596 aLoadInfo->GetRequestBlockingReason(), maybeCspToInheritInfo,
597 aLoadInfo->GetStoragePermission(), overriddenFingerprintingSettingsArg,
598 aLoadInfo->GetIsMetaRefresh(), aLoadInfo->GetLoadingEmbedderPolicy(),
599 aLoadInfo->GetIsOriginTrialCoepCredentiallessEnabledForTopLevel(),
600 unstrippedURI, interceptionInfoArg);
601
602 return NS_OK;
603}
604
605nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
606 const nsACString& aOriginRemoteType,
607 nsILoadInfo** outLoadInfo) {
608 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
609 outLoadInfo);
610}
611nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
612 const nsACString& aOriginRemoteType,
613 nsINode* aCspToInheritLoadingContext,
614 nsILoadInfo** outLoadInfo) {
615 RefPtr<LoadInfo> loadInfo;
616 nsresult rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType,
617 aCspToInheritLoadingContext,
618 getter_AddRefs(loadInfo));
619 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"
, 619); return rv; } } while (false)
;
620
621 loadInfo.forget(outLoadInfo);
622 return NS_OK;
623}
624
625nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& aLoadInfoArgs,
626 const nsACString& aOriginRemoteType,
627 LoadInfo** outLoadInfo) {
628 return LoadInfoArgsToLoadInfo(aLoadInfoArgs, aOriginRemoteType, nullptr,
629 outLoadInfo);
630}
631nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
632 const nsACString& aOriginRemoteType,
633 nsINode* aCspToInheritLoadingContext,
634 LoadInfo** outLoadInfo) {
635 nsCOMPtr<nsIPrincipal> loadingPrincipal;
636 if (loadInfoArgs.requestingPrincipalInfo().isSome()) {
637 auto loadingPrincipalOrErr =
638 PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo().ref());
639 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"
, 639)
) {
640 return loadingPrincipalOrErr.unwrapErr();
641 }
642 loadingPrincipal = loadingPrincipalOrErr.unwrap();
643 }
644
645 auto triggeringPrincipalOrErr =
646 PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo());
647 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"
, 647)
) {
648 return triggeringPrincipalOrErr.unwrapErr();
649 }
650 nsCOMPtr<nsIPrincipal> triggeringPrincipal =
651 triggeringPrincipalOrErr.unwrap();
652
653 nsCOMPtr<nsIPrincipal> principalToInherit;
654 nsCOMPtr<nsIPrincipal> flattenedPrincipalToInherit;
655 if (loadInfoArgs.principalToInheritInfo().isSome()) {
656 auto principalToInheritOrErr =
657 PrincipalInfoToPrincipal(loadInfoArgs.principalToInheritInfo().ref());
658 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"
, 658)
) {
659 return principalToInheritOrErr.unwrapErr();
660 }
661 flattenedPrincipalToInherit = principalToInheritOrErr.unwrap();
662 }
663
664 if (XRE_IsContentProcess()) {
665 auto targetBrowsingContextId = loadInfoArgs.frameBrowsingContextID()
666 ? loadInfoArgs.frameBrowsingContextID()
667 : loadInfoArgs.browsingContextID();
668 if (RefPtr<BrowsingContext> bc =
669 BrowsingContext::Get(targetBrowsingContextId)) {
670 auto [originalTriggeringPrincipal, originalPrincipalToInherit] =
671 bc->GetTriggeringAndInheritPrincipalsForCurrentLoad();
672
673 if (originalTriggeringPrincipal &&
674 originalTriggeringPrincipal->Equals(triggeringPrincipal)) {
675 triggeringPrincipal = originalTriggeringPrincipal;
676 }
677 if (originalPrincipalToInherit &&
678 (loadInfoArgs.securityFlags() &
679 nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL) &&
680 originalPrincipalToInherit->Equals(flattenedPrincipalToInherit)) {
681 principalToInherit = originalPrincipalToInherit;
682 }
683 }
684 }
685 if (!principalToInherit && loadInfoArgs.principalToInheritInfo().isSome()) {
686 principalToInherit = flattenedPrincipalToInherit;
687 }
688
689 nsCOMPtr<nsIPrincipal> topLevelPrincipal;
690 if (loadInfoArgs.topLevelPrincipalInfo().isSome()) {
691 auto topLevelPrincipalOrErr =
692 PrincipalInfoToPrincipal(loadInfoArgs.topLevelPrincipalInfo().ref());
693 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"
, 693)
) {
694 return topLevelPrincipalOrErr.unwrapErr();
695 }
696 topLevelPrincipal = topLevelPrincipalOrErr.unwrap();
697 }
698
699 nsCOMPtr<nsIURI> resultPrincipalURI;
700 if (loadInfoArgs.resultPrincipalURI().isSome()) {
701 resultPrincipalURI = DeserializeURI(loadInfoArgs.resultPrincipalURI());
702 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"
, 702); return NS_ERROR_UNEXPECTED; } } while (false)
;
703 }
704
705 // If we received this message from a content process, reset
706 // triggeringRemoteType to the process which sent us the message. If the
707 // parent sent us the message, we trust it to provide the correct triggering
708 // remote type.
709 //
710 // This means that the triggering remote type will be reset if a LoadInfo is
711 // bounced through a content process, as the LoadInfo can no longer be
712 // validated to be coming from the originally specified remote type.
713 nsCString triggeringRemoteType = loadInfoArgs.triggeringRemoteType();
714 if (aOriginRemoteType != NOT_REMOTE_TYPEVoidCString() &&
715 aOriginRemoteType != triggeringRemoteType) {
716 triggeringRemoteType = aOriginRemoteType;
717 }
718
719 RedirectHistoryArray redirectChainIncludingInternalRedirects;
720 for (const RedirectHistoryEntryInfo& entryInfo :
721 loadInfoArgs.redirectChainIncludingInternalRedirects()) {
722 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
723 RHEntryInfoToRHEntry(entryInfo);
724 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"
, 724); return NS_ERROR_UNEXPECTED; } } while (false)
;
725 redirectChainIncludingInternalRedirects.AppendElement(
726 redirectHistoryEntry.forget());
727 }
728
729 RedirectHistoryArray redirectChain;
730 for (const RedirectHistoryEntryInfo& entryInfo :
731 loadInfoArgs.redirectChain()) {
732 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
733 RHEntryInfoToRHEntry(entryInfo);
734 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"
, 734); return NS_ERROR_UNEXPECTED; } } while (false)
;
735 redirectChain.AppendElement(redirectHistoryEntry.forget());
736 }
737 nsTArray<nsCOMPtr<nsIPrincipal>> ancestorPrincipals;
738 nsTArray<uint64_t> ancestorBrowsingContextIDs;
739 if (XRE_IsParentProcess() &&
740 (nsContentUtils::InternalContentPolicyTypeToExternal(
741 loadInfoArgs.contentPolicyType()) !=
742 ExtContentPolicy::TYPE_DOCUMENT)) {
743 // Only fill out ancestor principals and browsing context IDs when we
744 // are deserializing LoadInfoArgs to be LoadInfo for a subresource
745 RefPtr<BrowsingContext> parentBC =
746 BrowsingContext::Get(loadInfoArgs.browsingContextID());
747 if (parentBC) {
748 LoadInfo::ComputeAncestors(parentBC->Canonical(), ancestorPrincipals,
749 ancestorBrowsingContextIDs);
750 }
751 }
752
753 Maybe<ClientInfo> clientInfo;
754 if (loadInfoArgs.clientInfo().isSome()) {
755 clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().ref()));
756 }
757
758 Maybe<ClientInfo> reservedClientInfo;
759 if (loadInfoArgs.reservedClientInfo().isSome()) {
760 reservedClientInfo.emplace(
761 ClientInfo(loadInfoArgs.reservedClientInfo().ref()));
762 }
763
764 Maybe<ClientInfo> initialClientInfo;
765 if (loadInfoArgs.initialClientInfo().isSome()) {
766 initialClientInfo.emplace(
767 ClientInfo(loadInfoArgs.initialClientInfo().ref()));
768 }
769
770 // We can have an initial client info or a reserved client info, but not both.
771 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"
, 772); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { *((volatile int*)__null) = 772; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
772 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"
, 772); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "reservedClientInfo.isNothing() || initialClientInfo.isNothing()"
")"); do { *((volatile int*)__null) = 772; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
773 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"
, 775); return NS_ERROR_UNEXPECTED; } } while (false)
774 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"
, 775); return NS_ERROR_UNEXPECTED; } } while (false)
775 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"
, 775); return NS_ERROR_UNEXPECTED; } } while (false)
;
776
777 Maybe<ServiceWorkerDescriptor> controller;
778 if (loadInfoArgs.controller().isSome()) {
779 controller.emplace(
780 ServiceWorkerDescriptor(loadInfoArgs.controller().ref()));
781 }
782
783 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
784 CookieJarSettings::Deserialize(loadInfoArgs.cookieJarSettings(),
785 getter_AddRefs(cookieJarSettings));
786
787 Maybe<RFPTarget> overriddenFingerprintingSettings;
788 if (loadInfoArgs.overriddenFingerprintingSettings().isSome()) {
789 overriddenFingerprintingSettings.emplace(
790 RFPTarget(loadInfoArgs.overriddenFingerprintingSettings().ref()));
791 }
792
793 nsCOMPtr<nsIContentSecurityPolicy> cspToInherit;
794 Maybe<mozilla::ipc::CSPInfo> cspToInheritInfo =
795 loadInfoArgs.cspToInheritInfo();
796 if (cspToInheritInfo.isSome()) {
797 nsCOMPtr<Document> doc = do_QueryInterface(aCspToInheritLoadingContext);
798 cspToInherit = CSPInfoToCSP(cspToInheritInfo.ref(), doc);
799 }
800
801 // Restore the loadingContext for frames using the BrowsingContext's
802 // embedder element. Note that this only works if the embedder is
803 // same-process, so won't be fission compatible.
804 nsCOMPtr<nsINode> loadingContext;
805 RefPtr<BrowsingContext> frameBrowsingContext =
806 BrowsingContext::Get(loadInfoArgs.frameBrowsingContextID());
807 if (frameBrowsingContext) {
808 loadingContext = frameBrowsingContext->GetEmbedderElement();
809 }
810
811 Maybe<bool> isThirdPartyContextToTopWindow;
812 if (loadInfoArgs.isThirdPartyContextToTopWindow().isSome()) {
813 isThirdPartyContextToTopWindow.emplace(
814 loadInfoArgs.isThirdPartyContextToTopWindow().ref());
815 }
816
817 nsCOMPtr<nsIInterceptionInfo> interceptionInfo;
818 if (loadInfoArgs.interceptionInfo().isSome()) {
819 const InterceptionInfoArg& interceptionInfoArg =
820 loadInfoArgs.interceptionInfo().ref();
821 nsCOMPtr<nsIPrincipal> triggeringPrincipal;
822 if (interceptionInfoArg.triggeringPrincipalInfo().isSome()) {
823 auto triggeringPrincipalOrErr = PrincipalInfoToPrincipal(
824 interceptionInfoArg.triggeringPrincipalInfo().ref());
825 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"
, 825)
) {
826 return triggeringPrincipalOrErr.unwrapErr();
827 }
828 triggeringPrincipal = triggeringPrincipalOrErr.unwrap();
829 }
830
831 RedirectHistoryArray redirectChain;
832 for (const RedirectHistoryEntryInfo& entryInfo :
833 interceptionInfoArg.redirectChain()) {
834 nsCOMPtr<nsIRedirectHistoryEntry> redirectHistoryEntry =
835 RHEntryInfoToRHEntry(entryInfo);
836 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"
, 836); return NS_ERROR_UNEXPECTED; } } while (false)
;
837 redirectChain.AppendElement(redirectHistoryEntry.forget());
838 }
839
840 interceptionInfo = new InterceptionInfo(
841 triggeringPrincipal, interceptionInfoArg.contentPolicyType(),
842 redirectChain, interceptionInfoArg.fromThirdParty());
843 }
844
845 RefPtr<mozilla::net::LoadInfo> loadInfo = new mozilla::net::LoadInfo(
846 loadingPrincipal, triggeringPrincipal, principalToInherit,
847 topLevelPrincipal, resultPrincipalURI, cookieJarSettings, cspToInherit,
848 triggeringRemoteType, loadInfoArgs.sandboxedNullPrincipalID(), clientInfo,
849 reservedClientInfo, initialClientInfo, controller,
850 loadInfoArgs.securityFlags(), loadInfoArgs.sandboxFlags(),
851 loadInfoArgs.triggeringSandboxFlags(), loadInfoArgs.triggeringWindowId(),
852 loadInfoArgs.triggeringStorageAccess(), loadInfoArgs.contentPolicyType(),
853 static_cast<LoadTainting>(loadInfoArgs.tainting()),
854 loadInfoArgs.blockAllMixedContent(),
855 loadInfoArgs.upgradeInsecureRequests(),
856 loadInfoArgs.browserUpgradeInsecureRequests(),
857 loadInfoArgs.browserDidUpgradeInsecureRequests(),
858 loadInfoArgs.browserWouldUpgradeInsecureRequests(),
859 loadInfoArgs.forceAllowDataURI(),
860 loadInfoArgs.allowInsecureRedirectToDataURI(),
861 loadInfoArgs.skipContentPolicyCheckForWebRequest(),
862 loadInfoArgs.originalFrameSrcLoad(),
863 loadInfoArgs.forceInheritPrincipalDropped(), loadInfoArgs.innerWindowID(),
864 loadInfoArgs.browsingContextID(), loadInfoArgs.frameBrowsingContextID(),
865 loadInfoArgs.initialSecurityCheckDone(),
866 loadInfoArgs.isInThirdPartyContext(), isThirdPartyContextToTopWindow,
867 loadInfoArgs.isFormSubmission(), loadInfoArgs.sendCSPViolationEvents(),
868 loadInfoArgs.originAttributes(),
869 std::move(redirectChainIncludingInternalRedirects),
870 std::move(redirectChain), std::move(ancestorPrincipals),
871 ancestorBrowsingContextIDs, loadInfoArgs.corsUnsafeHeaders(),
872 loadInfoArgs.forcePreflight(), loadInfoArgs.isPreflight(),
873 loadInfoArgs.loadTriggeredFromExternal(),
874 loadInfoArgs.serviceWorkerTaintingSynthesized(),
875 loadInfoArgs.documentHasUserInteracted(),
876 loadInfoArgs.allowListFutureDocumentsCreatedFromThisRedirectChain(),
877 loadInfoArgs.needForCheckingAntiTrackingHeuristic(),
878 loadInfoArgs.cspNonce(), loadInfoArgs.integrityMetadata(),
879 loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(),
880 loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(),
881 loadInfoArgs.textDirectiveUserActivation(),
882 // This function is only called for moving LoadInfo across processes.
883 // Same-document navigation won't cross process boundaries.
884 /* aIsSameDocumentNavigation */ false,
885 loadInfoArgs.allowDeprecatedSystemRequests(),
886 loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(),
887 loadInfoArgs.storagePermission(), overriddenFingerprintingSettings,
888 loadInfoArgs.isMetaRefresh(), loadInfoArgs.requestBlockingReason(),
889 loadingContext, loadInfoArgs.loadingEmbedderPolicy(),
890 loadInfoArgs.originTrialCoepCredentiallessEnabledForTopLevel(),
891 loadInfoArgs.unstrippedURI(), interceptionInfo,
892 loadInfoArgs.hasInjectedCookieForCookieBannerHandling(),
893 loadInfoArgs.wasSchemelessInput(), loadInfoArgs.httpsUpgradeTelemetry());
894
895 if (loadInfoArgs.isFromProcessingFrameAttributes()) {
896 loadInfo->SetIsFromProcessingFrameAttributes();
897 }
898
899 if (loadInfoArgs.isMediaRequest()) {
900 loadInfo->SetIsMediaRequest(true);
901
902 if (loadInfoArgs.isMediaInitialRequest()) {
903 loadInfo->SetIsMediaInitialRequest(true);
904 }
905 }
906
907 if (loadInfoArgs.isFromObjectOrEmbed()) {
908 loadInfo->SetIsFromObjectOrEmbed(true);
909 }
910
911 loadInfo.forget(outLoadInfo);
912 return NS_OK;
913}
914
915void LoadInfoToParentLoadInfoForwarder(
916 nsILoadInfo* aLoadInfo, ParentLoadInfoForwarderArgs* aForwarderArgsOut) {
917 Maybe<IPCServiceWorkerDescriptor> ipcController;
918 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
919 if (controller.isSome()) {
920 ipcController.emplace(controller.ref().ToIPC());
921 }
922
923 uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
924 Unused << aLoadInfo->GetTainting(&tainting);
925
926 Maybe<CookieJarSettingsArgs> cookieJarSettingsArgs;
927
928 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
929 nsresult rv =
930 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
931 CookieJarSettings* cs =
932 static_cast<CookieJarSettings*>(cookieJarSettings.get());
933 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings && cs->HasBeenChanged()) {
934 CookieJarSettingsArgs args;
935 cs->Serialize(args);
936 cookieJarSettingsArgs = Some(args);
937 }
938
939 nsCOMPtr<nsIURI> unstrippedURI;
940 Unused << aLoadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
941
942 Maybe<bool> isThirdPartyContextToTopWindow;
943 if (static_cast<LoadInfo*>(aLoadInfo)
944 ->HasIsThirdPartyContextToTopWindowSet()) {
945 isThirdPartyContextToTopWindow.emplace(
946 aLoadInfo->GetIsThirdPartyContextToTopWindow());
947 }
948
949 Maybe<uint64_t> overriddenFingerprintingSettingsArg;
950 Maybe<RFPTarget> overriddenFingerprintingSettings =
951 aLoadInfo->GetOverriddenFingerprintingSettings();
952
953 if (overriddenFingerprintingSettings) {
954 overriddenFingerprintingSettingsArg =
955 Some(uint64_t(overriddenFingerprintingSettings.ref()));
956 }
957
958 *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
959 aLoadInfo->GetAllowInsecureRedirectToDataURI(), ipcController, tainting,
960 aLoadInfo->GetSkipContentSniffing(), aLoadInfo->GetHttpsOnlyStatus(),
961 aLoadInfo->GetWasSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(),
962 aLoadInfo->GetHstsStatus(), aLoadInfo->GetHasValidUserGestureActivation(),
963 aLoadInfo->GetTextDirectiveUserActivation(),
964 aLoadInfo->GetAllowDeprecatedSystemRequests(),
965 aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
966 aLoadInfo->GetTriggeringSandboxFlags(),
967 aLoadInfo->GetTriggeringWindowId(),
968 aLoadInfo->GetTriggeringStorageAccess(),
969 aLoadInfo->GetServiceWorkerTaintingSynthesized(),
970 aLoadInfo->GetDocumentHasUserInteracted(),
971 aLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain(),
972 cookieJarSettingsArgs, aLoadInfo->GetContainerFeaturePolicyInfo(),
973 aLoadInfo->GetRequestBlockingReason(), aLoadInfo->GetStoragePermission(),
974 overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(),
975 isThirdPartyContextToTopWindow, aLoadInfo->GetIsInThirdPartyContext(),
976 unstrippedURI);
977}
978
979nsresult MergeParentLoadInfoForwarder(
980 ParentLoadInfoForwarderArgs const& aForwarderArgs, nsILoadInfo* aLoadInfo) {
981 nsresult rv;
982
983 rv = aLoadInfo->SetAllowInsecureRedirectToDataURI(
984 aForwarderArgs.allowInsecureRedirectToDataURI());
985 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"
, 985); return rv; } } while (false)
;
986
987 aLoadInfo->ClearController();
988 auto& controller = aForwarderArgs.controller();
989 if (controller.isSome()) {
990 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
991 }
992
993 if (aForwarderArgs.serviceWorkerTaintingSynthesized()) {
994 aLoadInfo->SynthesizeServiceWorkerTainting(
995 static_cast<LoadTainting>(aForwarderArgs.tainting()));
996 } else {
997 aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
998 }
999 rv = aLoadInfo->SetTextDirectiveUserActivation(
1000 aForwarderArgs.textDirectiveUserActivation());
1001 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"
, 1001); return rv; } } while (false)
;
1002
1003 rv = aLoadInfo->SetSkipContentSniffing(aForwarderArgs.skipContentSniffing());
1004 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"
, 1004); return rv; } } while (false)
;
1005
1006 rv = aLoadInfo->SetHttpsOnlyStatus(aForwarderArgs.httpsOnlyStatus());
1007 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"
, 1007); return rv; } } while (false)
;
1008
1009 rv = aLoadInfo->SetWasSchemelessInput(aForwarderArgs.wasSchemelessInput());
1010 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"
, 1010); return rv; } } while (false)
;
1011
1012 rv = aLoadInfo->SetHttpsUpgradeTelemetry(
1013 aForwarderArgs.httpsUpgradeTelemetry());
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->SetHstsStatus(aForwarderArgs.hstsStatus());
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->SetTriggeringSandboxFlags(
1020 aForwarderArgs.triggeringSandboxFlags());
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->SetTriggeringWindowId(aForwarderArgs.triggeringWindowId());
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->SetTriggeringStorageAccess(
1027 aForwarderArgs.triggeringStorageAccess());
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->SetHasValidUserGestureActivation(
1031 aForwarderArgs.hasValidUserGestureActivation());
1032 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"
, 1032); return rv; } } while (false)
;
1033
1034 rv = aLoadInfo->SetAllowDeprecatedSystemRequests(
1035 aForwarderArgs.allowDeprecatedSystemRequests());
1036 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"
, 1036); return rv; } } while (false)
;
1037
1038 rv = aLoadInfo->SetIsInDevToolsContext(aForwarderArgs.isInDevToolsContext());
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->SetParserCreatedScript(aForwarderArgs.parserCreatedScript());
1042 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"
, 1042); return rv; } } while (false)
;
1043
1044 MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetDocumentHasUserInteracted(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1045); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { *((volatile int*)__null) = 1045; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1045 aForwarderArgs.documentHasUserInteracted()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1045); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetDocumentHasUserInteracted( aForwarderArgs.documentHasUserInteracted()))"
")"); do { *((volatile int*)__null) = 1045; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1046 MOZ_ALWAYS_SUCCEEDS(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1049); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { *((volatile int*)__null) = 1049; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1047 aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1049); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { *((volatile int*)__null) = 1049; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1048 aForwarderArgsdo { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1049); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { *((volatile int*)__null) = 1049; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1049 .allowListFutureDocumentsCreatedFromThisRedirectChain()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain
( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1049); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain( aForwarderArgs .allowListFutureDocumentsCreatedFromThisRedirectChain()))"
")"); do { *((volatile int*)__null) = 1049; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1050 MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetRequestBlockingReason(do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1051); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { *((volatile int*)__null) = 1051; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1051 aForwarderArgs.requestBlockingReason()))do { if ((__builtin_expect(!!(((bool)(__builtin_expect(!!(!NS_FAILED_impl
(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason
()))), 1)))), 1))) { } else { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")", "/var/lib/jenkins/workspace/firefox-scan-build/ipc/glue/BackgroundUtils.cpp"
, 1051); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "NS_SUCCEEDED(aLoadInfo->SetRequestBlockingReason( aForwarderArgs.requestBlockingReason()))"
")"); do { *((volatile int*)__null) = 1051; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1052
1053 const Maybe<CookieJarSettingsArgs>& cookieJarSettingsArgs =
1054 aForwarderArgs.cookieJarSettings();
1055 if (cookieJarSettingsArgs.isSome()) {
1056 nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
1057 nsresult rv =
1058 aLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
1059 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && cookieJarSettings) {
1060 static_cast<CookieJarSettings*>(cookieJarSettings.get())
1061 ->Merge(cookieJarSettingsArgs.ref());
1062 }
1063 }
1064
1065 rv = aLoadInfo->SetStoragePermission(aForwarderArgs.storagePermission());
1066 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"
, 1066); return rv; } } while (false)
;
1067
1068 rv = aLoadInfo->SetIsMetaRefresh(aForwarderArgs.isMetaRefresh());
1069 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"
, 1069); return rv; } } while (false)
;
1070
1071 const Maybe<uint64_t> overriddenFingerprintingSettings =
1072 aForwarderArgs.overriddenFingerprintingSettings();
1073 if (overriddenFingerprintingSettings.isSome()) {
1074 aLoadInfo->SetOverriddenFingerprintingSettings(
1075 RFPTarget(overriddenFingerprintingSettings.ref()));
1076 }
1077
1078 static_cast<LoadInfo*>(aLoadInfo)->ClearIsThirdPartyContextToTopWindow();
1079 if (aForwarderArgs.isThirdPartyContextToTopWindow().isSome()) {
1080 rv = aLoadInfo->SetIsThirdPartyContextToTopWindow(
1081 aForwarderArgs.isThirdPartyContextToTopWindow().ref());
1082 }
1083 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"
, 1083); return rv; } } while (false)
;
1084
1085 rv = aLoadInfo->SetIsInThirdPartyContext(
1086 aForwarderArgs.isInThirdPartyContext());
1087 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"
, 1087); return rv; } } while (false)
;
1088
1089 rv = aLoadInfo->SetUnstrippedURI(aForwarderArgs.unstrippedURI());
1090 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"
, 1090); return rv; } } while (false)
;
1091
1092 if (aForwarderArgs.containerFeaturePolicyInfo()) {
1093 aLoadInfo->SetContainerFeaturePolicyInfo(
1094 *aForwarderArgs.containerFeaturePolicyInfo());
1095 }
1096
1097 return NS_OK;
1098}
1099
1100void LoadInfoToChildLoadInfoForwarder(
1101 nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
1102 Maybe<IPCClientInfo> ipcReserved;
1103 Maybe<ClientInfo> reserved(aLoadInfo->GetReservedClientInfo());
1104 if (reserved.isSome()) {
1105 ipcReserved.emplace(reserved.ref().ToIPC());
1106 }
1107
1108 Maybe<IPCClientInfo> ipcInitial;
1109 Maybe<ClientInfo> initial(aLoadInfo->GetInitialClientInfo());
1110 if (initial.isSome()) {
1111 ipcInitial.emplace(initial.ref().ToIPC());
1112 }
1113
1114 Maybe<IPCServiceWorkerDescriptor> ipcController;
1115 Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
1116 if (controller.isSome()) {
1117 ipcController.emplace(controller.ref().ToIPC());
1118 }
1119
1120 *aForwarderArgsOut =
1121 ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController,
1122 aLoadInfo->GetRequestBlockingReason());
1123}
1124
1125nsresult MergeChildLoadInfoForwarder(
1126 const ChildLoadInfoForwarderArgs& aForwarderArgs, nsILoadInfo* aLoadInfo) {
1127 Maybe<ClientInfo> reservedClientInfo;
1128 auto& ipcReserved = aForwarderArgs.reservedClientInfo();
1129 if (ipcReserved.isSome()) {
1130 reservedClientInfo.emplace(ClientInfo(ipcReserved.ref()));
1131 }
1132
1133 Maybe<ClientInfo> initialClientInfo;
1134 auto& ipcInitial = aForwarderArgs.initialClientInfo();
1135 if (ipcInitial.isSome()) {
1136 initialClientInfo.emplace(ClientInfo(ipcInitial.ref()));
1137 }
1138
1139 // There should only be at most one reserved or initial ClientInfo.
1140 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"
, 1140)
) {
1141 return NS_ERROR_FAILURE;
1142 }
1143
1144 // If we received no reserved or initial ClientInfo, then we must not
1145 // already have one set. There are no use cases where this should
1146 // happen and we don't have a way to clear the current value.
1147 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"
, 1150)
1148 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"
, 1150)
1149 (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"
, 1150)
1150 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"
, 1150)
) {
1151 return NS_ERROR_FAILURE;
1152 }
1153
1154 if (reservedClientInfo.isSome()) {
1155 // We need to override here instead of simply set the value. This
1156 // allows us to change the reserved client. This is necessary when
1157 // the ClientChannelHelper created a new reserved client in the
1158 // child-side of the redirect.
1159 aLoadInfo->OverrideReservedClientInfoInParent(reservedClientInfo.ref());
1160 } else if (initialClientInfo.isSome()) {
1161 aLoadInfo->SetInitialClientInfo(initialClientInfo.ref());
1162 }
1163
1164 aLoadInfo->ClearController();
1165 auto& controller = aForwarderArgs.controller();
1166 if (controller.isSome()) {
1167 aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
1168 }
1169
1170 uint32_t blockingReason = aForwarderArgs.requestBlockingReason();
1171 if (blockingReason) {
1172 // We only want to override when non-null, so that any earlier set non-null
1173 // value is not reverted to 0.
1174 aLoadInfo->SetRequestBlockingReason(blockingReason);
1175 }
1176
1177 return NS_OK;
1178}
1179
1180} // namespace ipc
1181} // namespace mozilla