Skip to content

Commit

Permalink
fs: validate writev fds consistently
Browse files Browse the repository at this point in the history
This commit updates the recently added writev methods
to validate file descriptors like the other fs methods do.

PR-URL: #29185
Refs: #25925
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Aug 20, 2019
1 parent acdc21b commit 4356836
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down

0 comments on commit 4356836

Please sign in to comment.