diff options
author | cjihrig <cjihrig@gmail.com> | 2018-05-20 18:36:40 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-05-26 04:48:37 +0300 |
commit | 751a42a30f35c2d04cfb80ce2b1ebec5d040a7e1 (patch) | |
tree | a87d0041da8d47cd4dc3907b78cc6e93eeca6d80 /lib | |
parent | f8464c869833bbbbb6db0d2f041aebd8aef3e095 (diff) |
fs: add length validation to fs.truncate()
This commit adds validation to the length parameter of
fs.truncate(). Prior to this commit, passing a non-number would
trigger a CHECK() in the binding layer.
PR-URL: https://github.com/nodejs/node/pull/20851
Fixes: https://github.com/nodejs/node/issues/20844
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/fs.js b/lib/fs.js index 221f79ae0bc..cfb4f2777b8 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -78,6 +78,7 @@ const { const { isUint32, validateAndMaskMode, + validateInteger, validateInt32, validateUint32 } = require('internal/validators'); @@ -609,6 +610,7 @@ function truncate(path, len, callback) { len = 0; } + validateInteger(len, 'len'); callback = maybeCallback(callback); fs.open(path, 'r+', function(er, fd) { if (er) return callback(er); |