Skip to content

Commit

Permalink
fs: validate mode in ReadStream and WriteStream
Browse files Browse the repository at this point in the history
  • Loading branch information
RaisinTen committed Feb 18, 2021
1 parent bb35b6e commit 90ed832
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/fs/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
} = require('internal/errors').codes;
const { deprecate } = require('internal/util');
const {
parseFileMode,
validateFunction,
validateInteger,
} = require('internal/validators');
Expand Down Expand Up @@ -168,7 +169,7 @@ function ReadStream(path, options) {
// Path will be ignored when fd is specified, so it can be falsy
this.path = toPathIfFileURL(path);
this.flags = options.flags === undefined ? 'r' : options.flags;
this.mode = options.mode === undefined ? 0o666 : options.mode;
this.mode = parseFileMode(options.mode, 'options.mode', 0o666);

importFd(this, options);

Expand Down Expand Up @@ -334,7 +335,7 @@ function WriteStream(path, options) {
// Path will be ignored when fd is specified, so it can be falsy
this.path = toPathIfFileURL(path);
this.flags = options.flags === undefined ? 'w' : options.flags;
this.mode = options.mode === undefined ? 0o666 : options.mode;
this.mode = parseFileMode(options.mode, 'options.mode', 0o666);

importFd(this, options);

Expand Down

0 comments on commit 90ed832

Please sign in to comment.