Skip to content

Commit ee2cb40

Browse files
committed
Add ARG_CHECKs to secp256k1_ec_pubkey_parse/secp256k1_ec_pubkey_serialize
This also makes secp256k1_ec_pubkey_parse's init of pubkey more unconditional.
1 parent 7450ef1 commit ee2cb40

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/secp256k1.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ int secp256k1_ec_pubkey_parse(const secp256k1_context* ctx, secp256k1_pubkey* pu
146146
secp256k1_ge Q;
147147

148148
(void)ctx;
149+
VERIFY_CHECK(ctx != NULL);
150+
ARG_CHECK(pubkey != NULL);
151+
memset(pubkey, 0, sizeof(*pubkey));
152+
ARG_CHECK(input != NULL);
149153
if (!secp256k1_eckey_pubkey_parse(&Q, input, inputlen)) {
150-
memset(pubkey, 0, sizeof(*pubkey));
151154
return 0;
152155
}
153156
secp256k1_pubkey_save(pubkey, &Q);
@@ -159,6 +162,10 @@ int secp256k1_ec_pubkey_serialize(const secp256k1_context* ctx, unsigned char *o
159162
secp256k1_ge Q;
160163

161164
(void)ctx;
165+
VERIFY_CHECK(ctx != NULL);
166+
ARG_CHECK(output != NULL);
167+
ARG_CHECK(outputlen != NULL);
168+
ARG_CHECK(pubkey != NULL);
162169
return (secp256k1_pubkey_load(ctx, &Q, pubkey) &&
163170
secp256k1_eckey_pubkey_serialize(&Q, output, outputlen, flags));
164171
}

0 commit comments

Comments
 (0)