| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b7c6ad5 commit 3a62202
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,31 +80,31 @@ function check(password, salt, keylen, options) { | |||
| 80 | 80 | if (options && options !== defaults) { | |
| 81 | 81 | let has_N, has_r, has_p; | |
| 82 | 82 | if (has_N = (options.N !== undefined)) { | |
| 83 | - validateUint32(options.N, 'N'); | ||
| 84 | 83 | N = options.N; | |
| 84 | + validateUint32(N, 'N'); | ||
| 85 | 85 | } | |
| 86 | 86 | if (options.cost !== undefined) { | |
| 87 | 87 | if (has_N) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER(); | |
| 88 | - validateUint32(options.cost, 'cost'); | ||
| 89 | 88 | N = options.cost; | |
| 89 | + validateUint32(N, 'cost'); | ||
| 90 | 90 | } | |
| 91 | 91 | if (has_r = (options.r !== undefined)) { | |
| 92 | - validateUint32(options.r, 'r'); | ||
| 93 | 92 | r = options.r; | |
| 93 | + validateUint32(r, 'r'); | ||
| 94 | 94 | } | |
| 95 | 95 | if (options.blockSize !== undefined) { | |
| 96 | 96 | if (has_r) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER(); | |
| 97 | - validateUint32(options.blockSize, 'blockSize'); | ||
| 98 | 97 | r = options.blockSize; | |
| 98 | + validateUint32(r, 'blockSize'); | ||
| 99 | 99 | } | |
| 100 | 100 | if (has_p = (options.p !== undefined)) { | |
| 101 | - validateUint32(options.p, 'p'); | ||
| 102 | 101 | p = options.p; | |
| 102 | + validateUint32(p, 'p'); | ||
| 103 | 103 | } | |
| 104 | 104 | if (options.parallelization !== undefined) { | |
| 105 | 105 | if (has_p) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER(); | |
| 106 | - validateUint32(options.parallelization, 'parallelization'); | ||
| 107 | 106 | p = options.parallelization; | |
| 107 | + validateUint32(p, 'parallelization'); | ||
| 108 | 108 | } | |
| 109 | 109 | if (options.maxmem !== undefined) { | |
| 110 | 110 | maxmem = options.maxmem; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,3 +235,38 @@ for (const { args, expected } of badargs) { | |||
| 235 | 235 | code: 'ERR_OUT_OF_RANGE' | |
| 236 | 236 | }); | |
| 237 | 237 | } | |
| 238 | + | ||
| 239 | + { | ||
| 240 | + // Regression test for https://github.com/nodejs/node/issues/28836. | ||
| 241 | + | ||
| 242 | + function testParameter(name, value) { | ||
| 243 | + let accessCount = 0; | ||
| 244 | + | ||
| 245 | + // Find out how often the value is accessed. | ||
| 246 | + crypto.scryptSync('', '', 1, { | ||
| 247 | + get [name]() { | ||
| 248 | + accessCount++; | ||
| 249 | + return value; | ||
| 250 | + } | ||
| 251 | + }); | ||
| 252 | + | ||
| 253 | + // Try to crash the process on the last access. | ||
| 254 | + common.expectsError(() => { | ||
| 255 | + crypto.scryptSync('', '', 1, { | ||
| 256 | + get [name]() { | ||
| 257 | + if (--accessCount === 0) | ||
| 258 | + return ''; | ||
| 259 | + return value; | ||
| 260 | + } | ||
| 261 | + }); | ||
| 262 | + }, { | ||
| 263 | + code: 'ERR_INVALID_ARG_TYPE' | ||
| 264 | + }); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + [ | ||
| 268 | + ['N', 16384], ['cost', 16384], | ||
| 269 | + ['r', 8], ['blockSize', 8], | ||
| 270 | + ['p', 1], ['parallelization', 1] | ||
| 271 | + ].forEach((arg) => testParameter(...arg)); | ||
| 272 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments