Skip to content

Commit 49402b1

Browse files
danbevMylesBorins
authored andcommitted
crypto: declare int return type for set_field
This commit updates the set_field function pointer to return an int, and also updates the lambdas with a return statement. PR-URL: #17468 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 7d3a843 commit 49402b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/node_crypto.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -5115,7 +5115,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
51155115
}
51165116

51175117
void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
5118-
void (*set_field)(DH*, BIGNUM*), const char* what) {
5118+
int (*set_field)(DH*, BIGNUM*), const char* what) {
51195119
Environment* env = Environment::GetCurrent(args);
51205120

51215121
DiffieHellman* dh;
@@ -5138,12 +5138,13 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
51385138
BN_bin2bn(reinterpret_cast<unsigned char*>(Buffer::Data(args[0])),
51395139
Buffer::Length(args[0]), nullptr);
51405140
CHECK_NE(num, nullptr);
5141-
set_field(dh->dh, num);
5141+
CHECK_EQ(1, set_field(dh->dh, num));
51425142
}
51435143

51445144

51455145
void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
5146-
SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, num, nullptr); },
5146+
SetKey(args,
5147+
[](DH* dh, BIGNUM* num) { return DH_set0_key(dh, num, nullptr); },
51475148
"Public key");
51485149
}
51495150

@@ -5154,7 +5155,8 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
51545155
// Node. See https://github.com/openssl/openssl/pull/4384.
51555156
#error "OpenSSL 1.1.0 revisions before 1.1.0g are not supported"
51565157
#endif
5157-
SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, nullptr, num); },
5158+
SetKey(args,
5159+
[](DH* dh, BIGNUM* num) { return DH_set0_key(dh, nullptr, num); },
51585160
"Private key");
51595161
}
51605162

src/node_crypto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ class DiffieHellman : public BaseObject {
712712
const BIGNUM* (*get_field)(const DH*),
713713
const char* err_if_null);
714714
static void SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
715-
void (*set_field)(DH*, BIGNUM*), const char* what);
715+
int (*set_field)(DH*, BIGNUM*), const char* what);
716716
bool VerifyContext();
717717

718718
bool initialised_;

0 commit comments

Comments
 (0)