From 70f4f08a9f0902056ac47271f9d3a761fcee4715 Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Sun, 10 Feb 2019 12:16:53 +0800 Subject: fs: harden validation of start option in createWriteStream PR-URL: https://github.com/nodejs/node/pull/25579 Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Luigi Pinca --- lib/internal/fs/streams.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/internal') diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 501c9ee4d2..7174990ebb 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -243,13 +243,7 @@ function WriteStream(path, options) { this.closed = false; if (this.start !== undefined) { - if (typeof this.start !== 'number') { - throw new ERR_INVALID_ARG_TYPE('start', 'number', this.start); - } - if (this.start < 0) { - const errVal = `{start: ${this.start}}`; - throw new ERR_OUT_OF_RANGE('start', '>= 0', errVal); - } + checkPosition(this.start, 'start'); this.pos = this.start; } -- cgit v1.2.3