Skip to content

Commit abc2801

Browse files
committed
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 <info@bnoordhuis.nl>
1 parent 09e9e2b commit abc2801

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/node_crypto.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,7 +5084,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
50845084
}
50855085

50865086
void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
5087-
void (*set_field)(DH*, BIGNUM*), const char* what) {
5087+
int (*set_field)(DH*, BIGNUM*), const char* what) {
50885088
Environment* env = Environment::GetCurrent(args);
50895089

50905090
DiffieHellman* dh;
@@ -5107,12 +5107,13 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
51075107
BN_bin2bn(reinterpret_cast<unsigned char*>(Buffer::Data(args[0])),
51085108
Buffer::Length(args[0]), nullptr);
51095109
CHECK_NE(num, nullptr);
5110-
set_field(dh->dh, num);
5110+
CHECK_EQ(1, set_field(dh->dh, num));
51115111
}
51125112

51135113

51145114
void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
5115-
SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, num, nullptr); },
5115+
SetKey(args,
5116+
[](DH* dh, BIGNUM* num) { return DH_set0_key(dh, num, nullptr); },
51165117
"Public key");
51175118
}
51185119

@@ -5123,7 +5124,8 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
51235124
// Node. See https://github.com/openssl/openssl/pull/4384.
51245125
#error "OpenSSL 1.1.0 revisions before 1.1.0g are not supported"
51255126
#endif
5126-
SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, nullptr, num); },
5127+
SetKey(args,
5128+
[](DH* dh, BIGNUM* num) { return DH_set0_key(dh, nullptr, num); },
51275129
"Private key");
51285130
}
51295131

src/node_crypto.h

Lines changed: 1 addition & 1 deletion
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)