-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds type validation to options fd & opts in `fs.createWriteStream` and `fs.createReadStream`. Fixes: #35178 PR-URL: #35187 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
- Loading branch information
1 parent
d08ea01
commit d4693ff
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
{ | ||
const fd = 'k'; | ||
|
||
assert.throws( | ||
() => { | ||
fs.createReadStream(null, { fd }); | ||
}, | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
}); | ||
|
||
assert.throws( | ||
() => { | ||
fs.createWriteStream(null, { fd }); | ||
}, | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
}); | ||
} | ||
|
||
{ | ||
const path = 46; | ||
|
||
assert.throws( | ||
() => { | ||
fs.createReadStream(path); | ||
}, | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
}); | ||
|
||
assert.throws( | ||
() => { | ||
fs.createWriteStream(path); | ||
}, | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
}); | ||
} |