From 41b099986da5a6d40c981c31e89fbc78d17ae5aa Mon Sep 17 00:00:00 2001 From: Darvesh Date: Fri, 20 Nov 2020 22:54:45 +0530 Subject: [PATCH] fs: throws error if position argument is bigint Fixes: https://github.com/nodejs/node/issues/36190 --- lib/fs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/fs.js b/lib/fs.js index cb9312c9d13fbe..3555ff1b41ed71 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -543,6 +543,9 @@ function read(fd, buffer, offset, length, position, callback) { validateOffsetLengthRead(offset, length, buffer.byteLength); + if(typeof position === 'bigint') + throw new ERR_INVALID_ARG_TYPE('position', 'number', position); + if (!NumberIsSafeInteger(position)) position = -1; @@ -595,6 +598,9 @@ function readSync(fd, buffer, offset, length, position) { validateOffsetLengthRead(offset, length, buffer.byteLength); + if(typeof position === 'bigint') + throw new ERR_INVALID_ARG_TYPE('position', 'number', position); + if (!NumberIsSafeInteger(position)) position = -1;