Title: [278692] trunk
Revision
278692
Author
[email protected]
Date
2021-06-09 21:52:56 -0700 (Wed, 09 Jun 2021)

Log Message

Null check page in generateCertificate
https://bugs.webkit.org/show_bug.cgi?id=226798

Patch by Rob Buis <[email protected]> on 2021-06-09
Reviewed by Youenn Fablet.

Source/WebCore:

Null check page in generateCertificate.

Test: http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::generateCertificate):

LayoutTests:

* http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash-expected.txt: Added.
* http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278691 => 278692)


--- trunk/LayoutTests/ChangeLog	2021-06-10 04:41:45 UTC (rev 278691)
+++ trunk/LayoutTests/ChangeLog	2021-06-10 04:52:56 UTC (rev 278692)
@@ -1,3 +1,13 @@
+2021-06-09  Rob Buis  <[email protected]>
+
+        Null check page in generateCertificate
+        https://bugs.webkit.org/show_bug.cgi?id=226798
+
+        Reviewed by Youenn Fablet.
+
+        * http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash-expected.txt: Added.
+        * http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html: Added.
+
 2021-06-09  Andres Gonzalez  <[email protected]>
 
         iOS - VoiceOver reads the old heading text when updated with heading.firstChild.data.

Added: trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash-expected.txt (0 => 278692)


--- trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash-expected.txt	2021-06-10 04:52:56 UTC (rev 278692)
@@ -0,0 +1,4 @@
+Passes if it doesn't crash!
+
+PASS RTCPeerConnection-generateCertificate-crash
+

Added: trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html (0 => 278692)


--- trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html	2021-06-10 04:52:56 UTC (rev 278692)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+async function promise_rejects(promise)
+{
+    return promise.then(() => {
+        return "FAIL";
+    }, (e) => {
+        return e.name === 'TypeError' ? 'PASS' : 'Got error ' + e;
+    })  
+}
+
+function with_iframe(url) {
+  return new Promise(function(resolve) {
+      var frame = document.createElement('iframe');
+      frame.src = ""
+      frame._onload_ = function() { resolve(frame); };
+      document.body.appendChild(frame);
+    });
+}
+
+promise_test(async (t) => {
+  const iframe = await with_iframe('/');
+  const pc = iframe.contentWindow.RTCPeerConnection;
+  iframe.remove();
+  return promise_rejects(pc.generateCertificate({ name: 'ECDSA', namedCurve: 'P-256'}));
+});
+</script>
+Passes if it doesn't crash!
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (278691 => 278692)


--- trunk/Source/WebCore/ChangeLog	2021-06-10 04:41:45 UTC (rev 278691)
+++ trunk/Source/WebCore/ChangeLog	2021-06-10 04:52:56 UTC (rev 278692)
@@ -1,3 +1,17 @@
+2021-06-09  Rob Buis  <[email protected]>
+
+        Null check page in generateCertificate
+        https://bugs.webkit.org/show_bug.cgi?id=226798
+
+        Reviewed by Youenn Fablet.
+
+        Null check page in generateCertificate.
+
+        Test: http/wpt/webrtc/RTCPeerConnection-generateCertificate-crash.html
+
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::generateCertificate):
+
 2021-06-09  Cameron McCormack  <[email protected]>
 
         Add window.internals.log()

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (278691 => 278692)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2021-06-10 04:41:45 UTC (rev 278691)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2021-06-10 04:52:56 UTC (rev 278692)
@@ -606,7 +606,12 @@
 void PeerConnectionBackend::generateCertificate(Document& document, const CertificateInformation& info, DOMPromiseDeferred<IDLInterface<RTCCertificate>>&& promise)
 {
 #if USE(LIBWEBRTC)
-    LibWebRTCCertificateGenerator::generateCertificate(document.securityOrigin(), document.page()->libWebRTCProvider(), info, WTFMove(promise));
+    auto* page = document.page();
+    if (!page) {
+        promise.reject(InvalidStateError);
+        return;
+    }
+    LibWebRTCCertificateGenerator::generateCertificate(document.securityOrigin(), page->libWebRTCProvider(), info, WTFMove(promise));
 #else
     UNUSED_PARAM(document);
     UNUSED_PARAM(expires);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to