Skip to content

Commit e34258e

Browse files
committed
Add missing null check for ctx and input keys in the public API
1 parent 55ad72a commit e34258e

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
@@ -740,6 +740,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
740740
secp256k1_gej Qj;
741741
secp256k1_ge Q;
742742

743+
VERIFY_CHECK(ctx != NULL);
743744
ARG_CHECK(pubnonce != NULL);
744745
memset(pubnonce, 0, sizeof(*pubnonce));
745746
ARG_CHECK(n >= 1);
@@ -748,6 +749,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
748749
secp256k1_gej_set_infinity(&Qj);
749750

750751
for (i = 0; i < n; i++) {
752+
ARG_CHECK(pubnonces[i] != NULL);
751753
secp256k1_pubkey_load(ctx, &Q, pubnonces[i]);
752754
secp256k1_gej_add_ge(&Qj, &Qj, &Q);
753755
}

0 commit comments

Comments
 (0)