Title: [253206] trunk/Source
Revision
253206
Author
[email protected]
Date
2019-12-06 08:06:12 -0800 (Fri, 06 Dec 2019)

Log Message

Stop using reserveCapacity() / reserveInitialCapacity() in IPC decoders
https://bugs.webkit.org/show_bug.cgi?id=204930
<rdar://problem/57682737>

Reviewed by Ryosuke Niwa.

This is IPC hardening since the size we use to reserve the capacity is encoded over IPC
and cannot be trusted in some cases.

Source/WebCore:

* page/csp/ContentSecurityPolicyResponseHeaders.h:
(WebCore::ContentSecurityPolicyResponseHeaders::decode):

Source/WebKit:

* Platform/IPC/ArgumentCoders.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<Vector<RefPtr<SecurityOrigin>>>::decode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253205 => 253206)


--- trunk/Source/WebCore/ChangeLog	2019-12-06 14:37:43 UTC (rev 253205)
+++ trunk/Source/WebCore/ChangeLog	2019-12-06 16:06:12 UTC (rev 253206)
@@ -1,3 +1,17 @@
+2019-12-05  Chris Dumez  <[email protected]>
+
+        Stop using reserveCapacity() / reserveInitialCapacity() in IPC decoders
+        https://bugs.webkit.org/show_bug.cgi?id=204930
+        <rdar://problem/57682737>
+
+        Reviewed by Ryosuke Niwa.
+
+        This is IPC hardening since the size we use to reserve the capacity is encoded over IPC
+        and cannot be trusted in some cases.
+
+        * page/csp/ContentSecurityPolicyResponseHeaders.h:
+        (WebCore::ContentSecurityPolicyResponseHeaders::decode):
+
 2019-12-06  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] Wire line counting functions in RenderBlockFlow

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicyResponseHeaders.h (253205 => 253206)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicyResponseHeaders.h	2019-12-06 14:37:43 UTC (rev 253205)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicyResponseHeaders.h	2019-12-06 16:06:12 UTC (rev 253206)
@@ -74,7 +74,6 @@
     uint64_t headersSize;
     if (!decoder.decode(headersSize))
         return false;
-    headers.m_headers.reserveCapacity(static_cast<size_t>(headersSize));
     for (size_t i = 0; i < headersSize; ++i) {
         String header;
         if (!decoder.decode(header))
@@ -84,6 +83,7 @@
             return false;
         headers.m_headers.append(std::make_pair(header, headerType));
     }
+    headers.m_headers.shrinkToFit();
 
     if (!decoder.decode(headers.m_httpStatusCode))
         return false;

Modified: trunk/Source/WebKit/ChangeLog (253205 => 253206)


--- trunk/Source/WebKit/ChangeLog	2019-12-06 14:37:43 UTC (rev 253205)
+++ trunk/Source/WebKit/ChangeLog	2019-12-06 16:06:12 UTC (rev 253206)
@@ -1,3 +1,18 @@
+2019-12-05  Chris Dumez  <[email protected]>
+
+        Stop using reserveCapacity() / reserveInitialCapacity() in IPC decoders
+        https://bugs.webkit.org/show_bug.cgi?id=204930
+        <rdar://problem/57682737>
+
+        Reviewed by Ryosuke Niwa.
+
+        This is IPC hardening since the size we use to reserve the capacity is encoded over IPC
+        and cannot be trusted in some cases.
+
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<Vector<RefPtr<SecurityOrigin>>>::decode):
+
 2019-12-06  youenn fablet  <[email protected]>
 
         Protect WebRTC network monitoring to wait forever in edge cases

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (253205 => 253206)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-12-06 14:37:43 UTC (rev 253205)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-12-06 16:06:12 UTC (rev 253206)
@@ -378,7 +378,6 @@
             return WTF::nullopt;
 
         HashMapType hashMap;
-        hashMap.reserveInitialCapacity(hashMapSize);
         for (uint32_t i = 0; i < hashMapSize; ++i) {
             Optional<KeyArg> key;
             decoder >> key;

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (253205 => 253206)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2019-12-06 14:37:43 UTC (rev 253205)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2019-12-06 16:06:12 UTC (rev 253206)
@@ -3034,13 +3034,14 @@
     if (!decoder.decode(dataSize))
         return false;
 
-    origins.reserveInitialCapacity(dataSize);
     for (uint64_t i = 0; i < dataSize; ++i) {
         auto decodedOriginRefPtr = SecurityOrigin::decode(decoder);
         if (!decodedOriginRefPtr)
             return false;
-        origins.uncheckedAppend(decodedOriginRefPtr.releaseNonNull());
+        origins.append(decodedOriginRefPtr.releaseNonNull());
     }
+    origins.shrinkToFit();
+
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to