Skip to content

Commit f9113fd

Browse files
tniessencodebytere
authored andcommittedMar 30, 2020
crypto: turn impossible DH errors into assertions
PR-URL: #31934 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 54395c6 commit f9113fd

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed
 

‎src/node_crypto.cc

+2-10
Original file line numberDiff line numberDiff line change
@@ -5884,11 +5884,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
58845884

58855885
ClearErrorOnReturn clear_error_on_return;
58865886

5887-
if (args.Length() == 0) {
5888-
return THROW_ERR_MISSING_ARGS(
5889-
env, "Other party's public key argument is mandatory");
5890-
}
5891-
5887+
CHECK_EQ(args.Length(), 1);
58925888
THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Other party's public key");
58935889
ArrayBufferViewContents<unsigned char> key_buf(args[0].As<ArrayBufferView>());
58945890
BignumPointer key(BN_bin2bn(key_buf.data(), key_buf.length(), nullptr));
@@ -5948,11 +5944,7 @@ void DiffieHellman::SetKey(const FunctionCallbackInfo<Value>& args,
59485944

59495945
char errmsg[64];
59505946

5951-
if (args.Length() == 0) {
5952-
snprintf(errmsg, sizeof(errmsg), "%s argument is mandatory", what);
5953-
return THROW_ERR_MISSING_ARGS(env, errmsg);
5954-
}
5955-
5947+
CHECK_EQ(args.Length(), 1);
59565948
if (!Buffer::HasInstance(args[0])) {
59575949
snprintf(errmsg, sizeof(errmsg), "%s must be a buffer", what);
59585950
return THROW_ERR_INVALID_ARG_TYPE(env, errmsg);

0 commit comments

Comments
 (0)
Please sign in to comment.