Bug 226640

Summary: FileReader.readAsArrayBuffer misses checking for the type of blob param
Product: WebKit Reporter: zyscoder <zyscoder>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, aestes, bugs-noreply, cdumez, darin, esprehn+autocc, ews-watchlist, ggaren, kondapallykalyan, mcatanzaro, rniwa, sam, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP Patch
none
Patch none

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].