diff options
author | cjihrig <cjihrig@gmail.com> | 2019-07-26 10:32:40 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-07-29 03:33:28 -1000 |
commit | 92ca2c208bf8c1a8abb21df800619b2890f72461 (patch) | |
tree | 840d53a7d9f4099e711a4cab379c954623709195 /lib/internal/crypto/hash.js | |
parent | 62a809fa54949fb1416b2462f995bb98037db2d0 (diff) | |
download | android-node-v8-92ca2c208bf8c1a8abb21df800619b2890f72461.tar.gz android-node-v8-92ca2c208bf8c1a8abb21df800619b2890f72461.tar.bz2 android-node-v8-92ca2c208bf8c1a8abb21df800619b2890f72461.zip |
crypto: add null check to outputLength logic
The Hash constructor's outputLength logic checks if the options
input is an object, but doesn't check for null objects. This
commit adds that check.
PR-URL: https://github.com/nodejs/node/pull/28864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/internal/crypto/hash.js')
-rw-r--r-- | lib/internal/crypto/hash.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js index 667624dce0..38b125e5f2 100644 --- a/lib/internal/crypto/hash.js +++ b/lib/internal/crypto/hash.js @@ -36,7 +36,8 @@ function Hash(algorithm, options) { if (!(this instanceof Hash)) return new Hash(algorithm, options); validateString(algorithm, 'algorithm'); - const xofLen = typeof options === 'object' ? options.outputLength : undefined; + const xofLen = typeof options === 'object' && options !== null ? + options.outputLength : undefined; if (xofLen !== undefined) validateUint32(xofLen, 'options.outputLength'); this[kHandle] = new _Hash(algorithm, xofLen); |