Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Null dereference in PDFPlugin::snapshot()
https://bugs.webkit.org/show_bug.cgi?id=217668

Patch by Julian Gonzalez <julian_a_gonzalez@apple.com> on 2020-10-13
Reviewed by Ryosuke Niwa.

Source/WebKit:

Add a null pointer check in PDFPlugin's snapshot method
to prevent a crash if the backing store's size
isn't sufficient for the ShareableBitmap.

Test: plugins/pdf-plugin-null-onloaddeddata.html

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::snapshot):

LayoutTests:

Add new pass-if-no-crash test to catch crash in PDFPlugin
snapshotting.

* plugins/pdf-plugin-null-onloaddeddata-expected.txt: Added.
* plugins/pdf-plugin-null-onloaddeddata.html: Added.

Canonical link: https://commits.webkit.org/230427@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268432 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Julian Gonzalez authored and webkit-commit-queue committed Oct 13, 2020
1 parent d078e28 commit 51a7ebc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
2020-10-13 Julian Gonzalez <julian_a_gonzalez@apple.com>

Null dereference in PDFPlugin::snapshot()
https://bugs.webkit.org/show_bug.cgi?id=217668

Reviewed by Ryosuke Niwa.

Add new pass-if-no-crash test to catch crash in PDFPlugin
snapshotting.

* plugins/pdf-plugin-null-onloaddeddata-expected.txt: Added.
* plugins/pdf-plugin-null-onloaddeddata.html: Added.

2020-10-13 Chris Dumez <cdumez@apple.com>

WebAudio tests are crashing in debug when enabling the GPU process
Expand Down
@@ -0,0 +1,4 @@
This tests determining the PDF plugin does not crash upon a null onloadeddata variable.

PASS

22 changes: 22 additions & 0 deletions LayoutTests/plugins/pdf-plugin-null-onloaddeddata.html
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<head>
<style>
embed, body { zoom: 61; }
</style>
</head>
<body onload=pdfonload()>
<p>This tests determining the PDF plugin does not crash upon a null onloadeddata variable.</p>
<div id="result">FAIL</div>
<embed id="testPlugin" type="application/pdf"></embed>
<script>
function pdfonload() {
testPlugin.onloadeddata = null;

if (window.testRunner)
testRunner.dumpAsText();

result.textContent = 'PASS';
}
</script>
</body>
</html>
16 changes: 16 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,19 @@
2020-10-13 Julian Gonzalez <julian_a_gonzalez@apple.com>

Null dereference in PDFPlugin::snapshot()
https://bugs.webkit.org/show_bug.cgi?id=217668

Reviewed by Ryosuke Niwa.

Add a null pointer check in PDFPlugin's snapshot method
to prevent a crash if the backing store's size
isn't sufficient for the ShareableBitmap.

Test: plugins/pdf-plugin-null-onloaddeddata.html

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::snapshot):

2020-10-12 Ryosuke Niwa <rniwa@webkit.org>

IPC testing JS API should expose a reply and describe the list of arguments for each message
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Expand Up @@ -1948,6 +1948,8 @@ static void jsPDFDocFinalize(JSObjectRef object)
backingStoreSize.scale(contentsScaleFactor);

auto bitmap = ShareableBitmap::createShareable(backingStoreSize, { });
if (!bitmap)
return nullptr;
auto context = bitmap->createGraphicsContext();
if (!context)
return nullptr;
Expand Down

0 comments on commit 51a7ebc

Please sign in to comment.