Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5f214c

Browse filesBrowse files
tniessenMoLow
authored andcommitted
crypto: replace THROW with CHECK for scrypt keylen
The JS layer already uses validateInt32(keylen, 'keylen', 0) to ensure that the keylen argument fits into a signed 32-bit integer, thus, the THROW statement in C++ is unreachable (unless the binding is accessed directly, of course). PR-URL: #47407 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 64a5fe0 commit a5f214c
Copy full SHA for a5f214c

File tree

Expand file treeCollapse file tree

2 files changed

+9
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-4
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_scrypt.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_scrypt.cc
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ Maybe<bool> ScryptTraits::AdditionalConfig(
109109
}
110110

111111
params->length = args[offset + 6].As<Int32>()->Value();
112-
if (params->length < 0) {
113-
THROW_ERR_OUT_OF_RANGE(env, "length must be <= %d", INT_MAX);
114-
return Nothing<bool>();
115-
}
112+
CHECK_GE(params->length, 0);
116113

117114
return Just(true);
118115
}
Collapse file

‎test/parallel/test-crypto-scrypt.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-scrypt.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,18 @@ const badargs = [
143143
args: ['', '', -42],
144144
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
145145
},
146+
{
147+
args: ['', '', 2 ** 31],
148+
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
149+
},
146150
{
147151
args: ['', '', 2147485780],
148152
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
149153
},
154+
{
155+
args: ['', '', 2 ** 32],
156+
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
157+
},
150158
];
151159

152160
for (const options of good) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.