Skip to content

Commit 5a08c1b

Browse files
committed
Add ARG_CHECKs to ensure "array of pointers" elements are non-NULL
1 parent e7f7083 commit 5a08c1b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/modules/musig/keyagg_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ int secp256k1_musig_pubkey_agg(const secp256k1_context* ctx, secp256k1_xonly_pub
177177
}
178178
ARG_CHECK(pubkeys != NULL);
179179
ARG_CHECK(n_pubkeys > 0);
180+
for (i = 0; i < n_pubkeys; i++) {
181+
ARG_CHECK(pubkeys[i] != NULL);
182+
}
180183

181184
ecmult_data.ctx = ctx;
182185
ecmult_data.pks = pubkeys;

src/modules/musig/session_impl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,15 @@ static int secp256k1_musig_sum_pubnonces(const secp256k1_context* ctx, secp256k1
521521
int secp256k1_musig_nonce_agg(const secp256k1_context* ctx, secp256k1_musig_aggnonce *aggnonce, const secp256k1_musig_pubnonce * const* pubnonces, size_t n_pubnonces) {
522522
secp256k1_gej aggnonce_ptsj[2];
523523
secp256k1_ge aggnonce_pts[2];
524+
size_t i;
525+
524526
VERIFY_CHECK(ctx != NULL);
525527
ARG_CHECK(aggnonce != NULL);
526528
ARG_CHECK(pubnonces != NULL);
527529
ARG_CHECK(n_pubnonces > 0);
530+
for (i = 0; i < n_pubnonces; i++) {
531+
ARG_CHECK(pubnonces[i] != NULL);
532+
}
528533

529534
if (!secp256k1_musig_sum_pubnonces(ctx, aggnonce_ptsj, pubnonces, n_pubnonces)) {
530535
return 0;
@@ -782,6 +787,9 @@ int secp256k1_musig_partial_sig_agg(const secp256k1_context* ctx, unsigned char
782787
ARG_CHECK(session != NULL);
783788
ARG_CHECK(partial_sigs != NULL);
784789
ARG_CHECK(n_sigs > 0);
790+
for (i = 0; i < n_sigs; i++) {
791+
ARG_CHECK(partial_sigs[i] != NULL);
792+
}
785793

786794
if (!secp256k1_musig_session_load(ctx, &session_i, session)) {
787795
return 0;

src/secp256k1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,13 @@ static int secp256k1_ec_pubkey_sort_cmp(const void* pk1, const void* pk2, void *
325325
}
326326

327327
int secp256k1_ec_pubkey_sort(const secp256k1_context* ctx, const secp256k1_pubkey **pubkeys, size_t n_pubkeys) {
328+
size_t i;
329+
328330
VERIFY_CHECK(ctx != NULL);
329331
ARG_CHECK(pubkeys != NULL);
332+
for (i = 0; i < n_pubkeys; i++) {
333+
ARG_CHECK(pubkeys[i] != NULL);
334+
}
330335

331336
/* Suppress wrong warning (fixed in MSVC 19.33) */
332337
#if defined(_MSC_VER) && (_MSC_VER < 1933)

0 commit comments

Comments
 (0)