Bug 226640 - FileReader.readAsArrayBuffer misses checking for the type of blob param
Summary: FileReader.readAsArrayBuffer misses checking for the type of blob param
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-04 05:12 PDT by zyscoder@gmail.com
Modified: 2021-06-16 12:58 PDT (History)
14 users (show)

See Also:


Attachments
WIP Patch (4.50 KB, patch)
2021-06-16 11:07 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (10.02 KB, patch)
2021-06-16 12:01 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zyscoder@gmail.com 2021-06-04 05:12:55 PDT
Steps to reproduce:

(1) Open a tab and navigate to any URL;
(2) Run the following code in the Console of Devtools:
```
new FileReader().readAsArrayBuffer(undefined);
```
(3) Then this code would be evaluated successfully without throwing any exception.

Actual results:

This code is evaluated successfully without throwing any exception.

Expected results:

FileReader.readAsArrayBuffer asks a Blob type object as its parameter, but Webkit doesn't check the type of the param in this code. A TypeError should be thrown in this code.

BTW, both Chrome and Firefox throw exceptions:
Chrome: `VM1217:1 Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.`
Firefox: `Uncaught TypeError: FileReader.readAsArrayBuffer: Argument 1 is not an object.`
Comment 1 Michael Catanzaro 2021-06-04 06:49:54 PDT
Hi, please don't use the WebKitGTK component for these general web content bugs. It's for known or suspected platform-specific issues only. You can use the Hardware field to indicate that you're using Linux.
Comment 2 Radar WebKit Bug Importer 2021-06-11 05:13:18 PDT
<rdar://problem/79193198>
Comment 3 Chris Dumez 2021-06-16 11:07:48 PDT
Created attachment 431567 [details]
WIP Patch
Comment 4 Chris Dumez 2021-06-16 12:01:19 PDT
Created attachment 431583 [details]
Patch
Comment 5 youenn fablet 2021-06-16 12:25:32 PDT
Comment on attachment 431583 [details]
Patch

Strange that we do not have any WPT test
Comment 6 Chris Dumez 2021-06-16 12:43:57 PDT
(In reply to youenn fablet from comment #5)
> Comment on attachment 431583 [details]
> Patch
> 
> Strange that we do not have any WPT test

Indeed. I'll resync the WPT tests in a follow-up as we seem a bit out of sync.
Comment 7 EWS 2021-06-16 12:58:39 PDT
Committed r278951 (238880@main): <https://commits.webkit.org/238880@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431583 [details].