Skip to content

Commit 298b850

Browse files
committed
Add missing null check for ctx and input keys in the public API
1 parent aa5a2a4 commit 298b850

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/modules/recovery/main_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context*
4040
int ret = 1;
4141
int overflow = 0;
4242

43-
(void)ctx;
43+
VERIFY_CHECK(ctx != NULL);
4444
ARG_CHECK(sig != NULL);
4545
ARG_CHECK(input64 != NULL);
4646
ARG_CHECK(recid >= 0 && recid <= 3);
@@ -60,7 +60,7 @@ int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context*
6060
int secp256k1_ecdsa_recoverable_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, int *recid, const secp256k1_ecdsa_recoverable_signature* sig) {
6161
secp256k1_scalar r, s;
6262

63-
(void)ctx;
63+
VERIFY_CHECK(ctx != NULL);
6464
ARG_CHECK(output64 != NULL);
6565
ARG_CHECK(sig != NULL);
6666
ARG_CHECK(recid != NULL);
@@ -75,7 +75,7 @@ int secp256k1_ecdsa_recoverable_signature_convert(const secp256k1_context* ctx,
7575
secp256k1_scalar r, s;
7676
int recid;
7777

78-
(void)ctx;
78+
VERIFY_CHECK(ctx != NULL);
7979
ARG_CHECK(sig != NULL);
8080
ARG_CHECK(sigin != NULL);
8181

src/secp256k1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
715715
secp256k1_gej Qj;
716716
secp256k1_ge Q;
717717

718+
VERIFY_CHECK(ctx != NULL);
718719
ARG_CHECK(pubnonce != NULL);
719720
memset(pubnonce, 0, sizeof(*pubnonce));
720721
ARG_CHECK(n >= 1);
@@ -723,6 +724,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
723724
secp256k1_gej_set_infinity(&Qj);
724725

725726
for (i = 0; i < n; i++) {
727+
ARG_CHECK(pubnonces[i] != NULL);
726728
secp256k1_pubkey_load(ctx, &Q, pubnonces[i]);
727729
secp256k1_gej_add_ge(&Qj, &Qj, &Q);
728730
}

0 commit comments

Comments
 (0)