From 435683610b8559755f424c7714336b364d95c1b5 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 17 Aug 2019 13:02:53 -0400 Subject: [PATCH] fs: validate writev fds consistently This commit updates the recently added writev methods to validate file descriptors like the other fs methods do. PR-URL: https://github.com/nodejs/node/pull/29185 Refs: https://github.com/nodejs/node/pull/25925 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Yongsheng Zhang Reviewed-By: Jiawen Geng Reviewed-By: Anto Aravinth Reviewed-By: Trivikram Kamat --- lib/fs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 7b6b6d58ae31ef..56f1df576090cf 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -609,7 +609,7 @@ function writev(fd, buffers, position, callback) { callback(err, written || 0, buffers); } - validateUint32(fd, 'fd'); + validateInt32(fd, 'fd', 0); if (!isBuffersArray(buffers)) { throw new ERR_INVALID_ARG_TYPE('buffers', 'ArrayBufferView[]', buffers); @@ -634,7 +634,7 @@ Object.defineProperty(writev, internalUtil.customPromisifyArgs, { // fs.writevSync(fd, buffers[, position]); function writevSync(fd, buffers, position) { - validateUint32(fd, 'fd'); + validateInt32(fd, 'fd', 0); const ctx = {}; if (!isBuffersArray(buffers)) {