Bug Summary

File:Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
Warning:line 296, column 11
Local variable 'resource' is uncounted and unsafe

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple arm64-apple-ios26.2.0-simulator -Os -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name UnifiedSource133.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -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 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -target-sdk-version=26.2 -fdepfile-entry=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/SDKSettings.json -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fno-modulemap-allow-subdirectory-search -fdefine-target-os-macros -enable-tlsdesc -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone -dwarf-version=5 -debugger-tuning=lldb -fdebug-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -target-linker-version 1230.1 -fcoverage-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -resource-dir /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21 -dependency-file /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource133.d -skip-unused-modulemap-deps -MT dependencies -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-generated-files.hmap -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-project-headers.hmap -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/usr/include -iframework /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/System/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/PrivateFrameworks -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -include-pch /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PrecompiledHeaders/SharedPrecompiledHeaders/12151610001510045616/WebKit2Prefix.h.gch -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D NDEBUG -D HAVE_CORE_PREDICTION -D ENABLE_LOWER_FORMATREADERBUNDLE_CODESIGNING_REQUIREMENTS -D WEBKIT_BUNDLE_VERSION="625.1.10+" -D FRAMEWORK_NAME=WebKit -D __clang_analyzer__ -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-own-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-all-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/WebCore.framework/PrivateHeaders/ForwardingHeaders -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit/IPC -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/pal/graphics/WebGPU -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/pal/graphics/WebGPU -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/WebKitAdditions -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/WebKitAdditions -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webrtc -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webrtc -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webm -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webm -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources-normal/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/System/Library/PrivateFrameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/PrivateFrameworks -D __STDC_WANT_LIB_EXT1__=1 -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include -internal-isystem /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/Frameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/SubFrameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/Library/Frameworks -Wno-trigraphs -Werror -Wno-missing-field-initializers -Wmissing-prototypes -Wunreachable-code -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wall -Wc99-designator -Wconditional-uninitialized -Wextra -Wdeprecated-enum-enum-conversion -Wdeprecated-enum-float-conversion -Wenum-float-conversion -Wfinal-dtor-non-final-class -Wformat=2 -Wmisleading-indentation -Wpointer-to-int-cast -Wreorder-init-list -Wundef -Wunused-but-set-variable -Wvla -Werror=unguarded-availability -Wno-elaborated-enum-base -Wno-unused-parameter -Wcast-qual -Wchar-subscripts -Wextra-tokens -Winit-self -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wvla -Wliteral-conversion -Wthread-safety -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled -Wno-backend-plugin -Wunsafe-buffer-usage -Wno-unknown-warning-option -Wno-missing-field-initializers -Wno-nullability-completeness -std=c++2b -fdeprecated-macro -ferror-limit 19 -fmacro-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fno-implicit-modules -fskip-odr-check-in-gmf -fpascal-strings -fmax-type-align=16 -fdiagnostics-show-note-include-stack -vectorize-loops -vectorize-slp -fsafe-buffer-usage-suggestions -analyzer-output=html -analyzer-config report-in-main-source-file=true -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -analyzer-checker optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker security.insecureAPI.UncheckedReturn -analyzer-checker security.insecureAPI.getpw -analyzer-checker security.insecureAPI.gets -analyzer-checker security.insecureAPI.mkstemp -analyzer-checker security.insecureAPI.mktemp -analyzer-disable-checker security.insecureAPI.rand -analyzer-disable-checker security.insecureAPI.strcpy -analyzer-checker security.insecureAPI.vfork -analyzer-disable-checker alpha,apiModeling,core,cplusplus,deadcode,debug,fuchsia,nullability,optin,osx,security,unix,webkit -analyzer-checker alpha.webkit.ForwardDeclChecker,alpha.webkit.MemoryUnsafeCastChecker,alpha.webkit.NoDeleteChecker,alpha.webkit.NoUncheckedPtrMemberChecker,alpha.webkit.NoUnretainedMemberChecker,alpha.webkit.RetainPtrCtorAdoptChecker,alpha.webkit.UncheckedCallArgsChecker,alpha.webkit.UncheckedLocalVarsChecker,alpha.webkit.UncountedCallArgsChecker,alpha.webkit.UncountedLocalVarsChecker,alpha.webkit.UnretainedCallArgsChecker,alpha.webkit.UnretainedLambdaCapturesChecker,alpha.webkit.UnretainedLocalVarsChecker,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,webkit.UncountedLambdaCapturesChecker -analyzer-config max-nodes=10000000 -analyzer-config verbose-report-filename=true -fdwarf2-cfi-asm -o /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource133.plist -x c++ /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit/unified-sources/UnifiedSource133.cpp
1/*
2 * Copyright (C) 2010-2025 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "NetworkProcessConnection.h"
28
29#include "LibWebRTCNetwork.h"
30#include "Logging.h"
31#include "NetworkConnectionToWebProcessMessages.h"
32#include "RTCDataChannelRemoteManager.h"
33#include "StorageAreaMap.h"
34#include "StorageAreaMapMessages.h"
35#include "WebBroadcastChannelRegistry.h"
36#include "WebBroadcastChannelRegistryMessages.h"
37#include "WebCacheStorageProvider.h"
38#include "WebCookieJar.h"
39#include "WebFileSystemStorageConnection.h"
40#include "WebFileSystemStorageConnectionMessages.h"
41#include "WebFrame.h"
42#include "WebIDBConnectionToServer.h"
43#include "WebIDBConnectionToServerMessages.h"
44#include "WebLoaderStrategy.h"
45#include "WebPage.h"
46#include "WebPageMessages.h"
47#include "WebPaymentCoordinator.h"
48#include "WebProcess.h"
49#include "WebRTCMonitor.h"
50#include "WebRTCMonitorMessages.h"
51#include "WebRTCResolverMessages.h"
52#include "WebResourceLoaderMessages.h"
53#include "WebSWClientConnection.h"
54#include "WebSWClientConnectionMessages.h"
55#include "WebSWContextManagerConnection.h"
56#include "WebSWContextManagerConnectionMessages.h"
57#include "WebServiceWorkerProvider.h"
58#include "WebSharedWorkerContextManagerConnection.h"
59#include "WebSharedWorkerContextManagerConnectionMessages.h"
60#include "WebSharedWorkerObjectConnection.h"
61#include "WebSharedWorkerObjectConnectionMessages.h"
62#include "WebSocketChannel.h"
63#include "WebSocketChannelMessages.h"
64#include "WebTransportSession.h"
65#include "WebTransportSessionMessages.h"
66#include <WebCore/BackgroundFetchRecordInformation.h>
67#include <WebCore/CachedResource.h>
68#include <WebCore/HTTPCookieAcceptPolicy.h>
69#include <WebCore/InspectorInstrumentationWebKit.h>
70#include <WebCore/MemoryCache.h>
71#include <WebCore/MessagePort.h>
72#include <WebCore/NavigationScheduler.h>
73#include <WebCore/Page.h>
74#include <WebCore/PermissionController.h>
75#include <WebCore/SharedBuffer.h>
76#include <pal/SessionID.h>
77
78#if USE(LIBRICE)(defined USE_LIBRICE && USE_LIBRICE)
79#include "RiceBackendProxy.h"
80#include "RiceBackendProxyMessages.h"
81#endif
82
83#if ENABLE(APPLE_PAY_REMOTE_UI)(defined 1 && 1)
84#include "WebPaymentCoordinatorMessages.h"
85#endif
86
87namespace WebKit {
88using namespace WebCore;
89
90NetworkProcessConnection::NetworkProcessConnection(IPC::Connection::Identifier&& connectionIdentifier, HTTPCookieAcceptPolicy cookieAcceptPolicy)
91 : m_connection(IPC::Connection::createClientConnection(WTF::move(connectionIdentifier)))
92 , m_cookieAcceptPolicy(cookieAcceptPolicy)
93{
94 m_connection->open(*this);
95
96#if USE(LIBWEBRTC)(defined 1 && 1)
97 if (WebRTCProvider::webRTCAvailable())
98 protect(WebProcess::singleton().libWebRTCNetwork())->setConnection(m_connection.copyRef());
99#endif
100}
101
102NetworkProcessConnection::~NetworkProcessConnection()
103{
104 m_connection->invalidate();
105}
106
107bool NetworkProcessConnection::dispatchMessage(IPC::Connection& connection, IPC::Decoder& decoder)
108{
109 if (decoder.messageReceiverName() == Messages::WebResourceLoader::messageReceiverName()) {
110 if (RefPtr webResourceLoader = protect(WebProcess::singleton().webLoaderStrategy())->webResourceLoaderForIdentifier(AtomicObjectIdentifier<WebCore::ResourceLoaderIdentifierType>(decoder.destinationID())))
111 webResourceLoader->didReceiveMessage(connection, decoder);
112 return true;
113 }
114 if (decoder.messageReceiverName() == Messages::WebBroadcastChannelRegistry::messageReceiverName()) {
115 WebProcess::singleton().broadcastChannelRegistry().didReceiveMessage(connection, decoder);
116 return true;
117 }
118 if (decoder.messageReceiverName() == Messages::WebSocketChannel::messageReceiverName()) {
119 WebProcess::singleton().webSocketChannelManager().didReceiveMessage(connection, decoder);
120 return true;
121 }
122 if (decoder.messageReceiverName() == Messages::WebPage::messageReceiverName()) {
123 if (RefPtr webPage = WebProcess::singleton().webPage(ObjectIdentifier<PageIdentifierType>(decoder.destinationID())))
124 webPage->didReceiveMessage(connection, decoder);
125 return true;
126 }
127 if (decoder.messageReceiverName() == Messages::StorageAreaMap::messageReceiverName()) {
128 if (auto storageAreaMap = WebProcess::singleton().storageAreaMap(ObjectIdentifier<StorageAreaMapIdentifierType>(decoder.destinationID())))
129 storageAreaMap->didReceiveMessage(connection, decoder);
130 return true;
131 }
132 if (decoder.messageReceiverName() == Messages::WebFileSystemStorageConnection::messageReceiverName()) {
133 protect(WebProcess::singleton().fileSystemStorageConnection())->didReceiveMessage(connection, decoder);
134 return true;
135 }
136 if (decoder.messageReceiverName() == Messages::WebTransportSession::messageReceiverName()) {
137 if (RefPtr webTransportSession = WebProcess::singleton().webTransportSession(WebTransportSessionIdentifier(decoder.destinationID())))
138 webTransportSession->didReceiveMessage(connection, decoder);
139 return true;
140 }
141
142#if USE(LIBWEBRTC)(defined 1 && 1)
143 if (decoder.messageReceiverName() == Messages::WebRTCMonitor::messageReceiverName()) {
144 Ref network = WebProcess::singleton().libWebRTCNetwork();
145 if (network->isActive())
146 protect(network->monitor())->didReceiveMessage(connection, decoder);
147 else
148 RELEASE_LOG_ERROR(WebRTC, "Received WebRTCMonitor message while libWebRTCNetwork is not active")clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option"
clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang
::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogWebRTC
.osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if
(os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({
clang diagnostic push clang diagnostic ignored "-Wvla" clang
diagnostic error "-Wformat" _Static_assert(__builtin_constant_p
("Received WebRTCMonitor message while libWebRTCNetwork is not active"
), "format/label/description argument must be a string constant"
); __attribute__((section("__TEXT,__oslogstring,cstring_literals"
),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG59"
) = "Received WebRTCMonitor message while libWebRTCNetwork is not active"
; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf
[__builtin_os_log_format_buffer_size("Received WebRTCMonitor message while libWebRTCNetwork is not active"
)]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp
, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf
, "Received WebRTCMonitor message while libWebRTCNetwork is not active"
), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); }
}) clang diagnostic pop
;
149 return true;
150 }
151 if (decoder.messageReceiverName() == Messages::WebRTCResolver::messageReceiverName()) {
152 Ref network = WebProcess::singleton().libWebRTCNetwork();
153 if (network->isActive())
154 network->resolver(AtomicObjectIdentifier<LibWebRTCResolverIdentifierType>(decoder.destinationID()))->didReceiveMessage(connection, decoder);
155 else
156 RELEASE_LOG_ERROR(WebRTC, "Received WebRTCResolver message while libWebRTCNetwork is not active")clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option"
clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang
::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogWebRTC
.osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if
(os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({
clang diagnostic push clang diagnostic ignored "-Wvla" clang
diagnostic error "-Wformat" _Static_assert(__builtin_constant_p
("Received WebRTCResolver message while libWebRTCNetwork is not active"
), "format/label/description argument must be a string constant"
); __attribute__((section("__TEXT,__oslogstring,cstring_literals"
),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG60"
) = "Received WebRTCResolver message while libWebRTCNetwork is not active"
; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf
[__builtin_os_log_format_buffer_size("Received WebRTCResolver message while libWebRTCNetwork is not active"
)]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp
, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf
, "Received WebRTCResolver message while libWebRTCNetwork is not active"
), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); }
}) clang diagnostic pop
;
157 return true;
158 }
159#endif
160
161#if USE(LIBRICE)(defined USE_LIBRICE && USE_LIBRICE)
162 if (decoder.messageReceiverName() == Messages::RiceBackendProxy::messageReceiverName()) {
163 if (RefPtr agent = WebProcess::singleton().gstreamerIceBackend(RiceBackendIdentifier(decoder.destinationID())))
164 agent->didReceiveMessage(connection, decoder);
165 return true;
166 }
167#endif
168
169 if (decoder.messageReceiverName() == Messages::WebIDBConnectionToServer::messageReceiverName()) {
170 if (RefPtr webIDBConnection = m_webIDBConnection)
171 webIDBConnection->didReceiveMessage(connection, decoder);
172 return true;
173 }
174
175 if (decoder.messageReceiverName() == Messages::WebSWClientConnection::messageReceiverName()) {
176 protect(serviceWorkerConnection())->didReceiveMessage(connection, decoder);
177 return true;
178 }
179 if (decoder.messageReceiverName() == Messages::WebSWContextManagerConnection::messageReceiverName()) {
180 ASSERT(SWContextManager::singleton().connection())((void)0);
181 if (RefPtr contextManagerConnection = SWContextManager::singleton().connection())
182 downcast<WebSWContextManagerConnection>(*contextManagerConnection).didReceiveMessage(connection, decoder);
183 return true;
184 }
185 if (decoder.messageReceiverName() == Messages::WebSharedWorkerObjectConnection::messageReceiverName()) {
186 protect(sharedWorkerConnection())->didReceiveMessage(connection, decoder);
187 return true;
188 }
189 if (decoder.messageReceiverName() == Messages::WebSharedWorkerContextManagerConnection::messageReceiverName()) {
190 ASSERT(SharedWorkerContextManager::singleton().connection())((void)0);
191 if (RefPtr contextManagerConnection = SharedWorkerContextManager::singleton().connection())
192 downcast<WebSharedWorkerContextManagerConnection>(*contextManagerConnection).didReceiveMessage(connection, decoder);
193 return true;
194 }
195
196#if ENABLE(APPLE_PAY_REMOTE_UI)(defined 1 && 1)
197 if (decoder.messageReceiverName() == Messages::WebPaymentCoordinator::messageReceiverName()) {
198 if (RefPtr webPage = WebProcess::singleton().webPage(ObjectIdentifier<PageIdentifierType>(decoder.destinationID())))
199 RefPtr { webPage->paymentCoordinator() }->didReceiveMessage(connection, decoder);
200 return true;
201 }
202#endif
203 return false;
204}
205
206bool NetworkProcessConnection::dispatchSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, UniqueRef<IPC::Encoder>& replyEncoder)
207{
208#if ENABLE(APPLE_PAY_REMOTE_UI)(defined 1 && 1)
209 if (decoder.messageReceiverName() == Messages::WebPaymentCoordinator::messageReceiverName()) {
210 if (RefPtr webPage = WebProcess::singleton().webPage(ObjectIdentifier<PageIdentifierType>(decoder.destinationID()))) {
211 RefPtr { webPage->paymentCoordinator() }->didReceiveSyncMessage(connection, decoder, replyEncoder);
212 return true;
213 }
214 return false;
215 }
216#endif
217 return false;
218}
219
220void NetworkProcessConnection::didClose(IPC::Connection&)
221{
222 // The NetworkProcess probably crashed.
223 Ref<NetworkProcessConnection> protector(*this);
224 WebProcess::singleton().networkProcessConnectionClosed(this);
225
226 if (auto idbConnection = std::exchange(m_webIDBConnection, nullptr))
227 idbConnection->connectionToServerLost();
228
229 if (auto swConnection = std::exchange(m_swConnection, nullptr))
230 swConnection->connectionToServerLost();
231}
232
233void NetworkProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::MessageName, const Vector<uint32_t>&)
234{
235}
236
237void NetworkProcessConnection::writeBlobsToTemporaryFilesForIndexedDB(const Vector<String>& blobURLs, CompletionHandler<void(Vector<String>&& filePaths)>&& completionHandler)
238{
239 m_connection->sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::WriteBlobsToTemporaryFilesForIndexedDB(blobURLs), WTF::move(completionHandler));
240}
241
242void NetworkProcessConnection::didFinishPingLoad(WebCore::ResourceLoaderIdentifier pingLoadIdentifier, ResourceError&& error, ResourceResponse&& response)
243{
244 protect(WebProcess::singleton().webLoaderStrategy())->didFinishPingLoad(pingLoadIdentifier, WTF::move(error), WTF::move(response));
245}
246
247void NetworkProcessConnection::didFinishPreconnection(WebCore::ResourceLoaderIdentifier preconnectionIdentifier, ResourceError&& error)
248{
249 protect(WebProcess::singleton().webLoaderStrategy())->didFinishPreconnection(preconnectionIdentifier, WTF::move(error));
250}
251
252void NetworkProcessConnection::setOnLineState(bool isOnLine)
253{
254 protect(WebProcess::singleton().webLoaderStrategy())->setOnLineState(isOnLine);
255}
256
257bool NetworkProcessConnection::cookiesEnabled() const
258{
259 return m_cookieAcceptPolicy != HTTPCookieAcceptPolicy::Never;
260}
261
262void NetworkProcessConnection::cookieAcceptPolicyChanged(HTTPCookieAcceptPolicy newPolicy)
263{
264 if (m_cookieAcceptPolicy == newPolicy)
265 return;
266
267 m_cookieAcceptPolicy = newPolicy;
268 WebProcess::singleton().cookieJar().clearCache();
269}
270
271#if HAVE(COOKIE_CHANGE_LISTENER_API)(defined 1 && 1)
272void NetworkProcessConnection::cookiesAdded(const String& host, Vector<WebCore::Cookie>&& cookies)
273{
274 WebProcess::singleton().cookieJar().cookiesAdded(host, WTF::move(cookies));
275}
276
277void NetworkProcessConnection::cookiesDeleted(const String& host, Vector<WebCore::Cookie>&& cookies)
278{
279 WebProcess::singleton().cookieJar().cookiesDeleted(host, WTF::move(cookies));
280}
281
282void NetworkProcessConnection::allCookiesDeleted()
283{
284 WebProcess::singleton().cookieJar().allCookiesDeleted();
285}
286#endif
287
288void NetworkProcessConnection::updateCachedCookiesEnabled()
289{
290 WebProcess::singleton().updateCachedCookiesEnabled();
291}
292
293#if ENABLE(SHAREABLE_RESOURCE)(defined 1 && 1)
294void NetworkProcessConnection::didCacheResource(const ResourceRequest& request, ShareableResource::Handle&& handle)
295{
296 auto* resource = MemoryCache::singleton().resourceForRequest(request, WebProcess::singleton().sessionID());
Local variable 'resource' is uncounted and unsafe
297 if (!resource)
298 return;
299
300 auto buffer = WTF::move(handle).tryWrapInSharedBuffer();
301 if (!buffer) {
302 LOG_ERROR("Unable to create FragmentedSharedBuffer from ShareableResource handle for resource url %s", request.url().string().utf8().data())((void)0);
303 return;
304 }
305
306 resource->tryReplaceEncodedData(*buffer);
307}
308#endif
309
310WebIDBConnectionToServer& NetworkProcessConnection::idbConnectionToServer()
311{
312 if (!m_webIDBConnection)
313 m_webIDBConnection = WebIDBConnectionToServer::create(WebProcess::singleton().sessionID());
314
315 return *m_webIDBConnection;
316}
317
318WebSWClientConnection& NetworkProcessConnection::serviceWorkerConnection()
319{
320 if (!m_swConnection)
321 m_swConnection = WebSWClientConnection::create();
322 return *m_swConnection;
323}
324
325WebSharedWorkerObjectConnection& NetworkProcessConnection::sharedWorkerConnection()
326{
327 if (!m_sharedWorkerConnection)
328 m_sharedWorkerConnection = WebSharedWorkerObjectConnection::create();
329 return *m_sharedWorkerConnection;
330}
331
332void NetworkProcessConnection::messagesAvailableForPort(const WebCore::MessagePortIdentifier& messagePortIdentifier)
333{
334 WebProcess::singleton().messagesAvailableForPort(messagePortIdentifier);
335}
336
337void NetworkProcessConnection::broadcastConsoleMessage(MessageSource source, MessageLevel level, const String& message)
338{
339 FAST_RETURN_IF_NO_FRONTENDS(void())if (!InspectorInstrumentationPublic::hasFrontends()) [[likely
]] return void();
;
340
341 Page::forEachPage([&] (auto& page) {
342 if (RefPtr localTopDocument = page.localTopDocument())
343 localTopDocument->addConsoleMessage(source, level, message);
344 });
345}
346
347void NetworkProcessConnection::loadCancelledDownloadRedirectRequestInFrame(WebCore::ResourceRequest&& request, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID)
348{
349 if (RefPtr webPage = WebProcess::singleton().webPage(pageID); webPage && WebProcess::singleton().webFrame(frameID)) {
350 LoadParameters loadParameters;
351 loadParameters.frameIdentifier = frameID;
352 loadParameters.request = request;
353 webPage->loadRequest(WTF::move(loadParameters));
354 } else
355 RELEASE_LOG_ERROR(Process, "Trying to load Invalid page or frame for %s", request.url().string().utf8().data())clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option"
clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic
ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang
::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogProcess
.osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if
(os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({
clang diagnostic push clang diagnostic ignored "-Wvla" clang
diagnostic error "-Wformat" _Static_assert(__builtin_constant_p
("Trying to load Invalid page or frame for %s"), "format/label/description argument must be a string constant"
); __attribute__((section("__TEXT,__oslogstring,cstring_literals"
),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG61"
) = "Trying to load Invalid page or frame for %s"; uint8_t _Alignas
(16) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size
("Trying to load Invalid page or frame for %s", request.url()
.string().utf8().data())]; _os_log_error_impl(&__dso_handle
, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format
(_os_fmt_buf, "Trying to load Invalid page or frame for %s", request
.url().string().utf8().data()), (uint32_t)sizeof(_os_fmt_buf)
) clang diagnostic pop ; }); } }) clang diagnostic pop
;
356}
357
358#if ENABLE(WEB_RTC)(defined 1 && 1)
359void NetworkProcessConnection::connectToRTCDataChannelRemoteSource(WebCore::RTCDataChannelIdentifier localIdentifier, WebCore::RTCDataChannelIdentifier remoteIdentifier, CompletionHandler<void(std::optional<bool>)>&& callback)
360{
361 callback(RTCDataChannelRemoteManager::singleton().connectToRemoteSource(localIdentifier, remoteIdentifier));
362}
363#endif
364
365void NetworkProcessConnection::storageAccessPermissionChanged(const WebCore::RegistrableDomain& topFrameDomain, const WebCore::RegistrableDomain& subFrameDomain)
366{
367 WebCore::PermissionController::singleton().storageAccessPermissionChanged(topFrameDomain, subFrameDomain);
368}
369
370} // namespace WebKit