fs: harden fs.read(params, callback) typecheck

PR-URL: https://github.com/nodejs/node/pull/42772
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
LiviaMedeiros 2022-04-18 19:54:40 +08:00 committed by Node.js GitHub Bot
parent 29953a0b88
commit 2275faac2b

View File

@ -639,6 +639,9 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
buffer = Buffer.alloc(16384);
}
if (params !== undefined) {
validateObject(params, 'options', { nullable: true });
}
({
offset = 0,
length = buffer.byteLength - offset,