Skip to content

Commit 5ea1fad

Browse files
morehouserustyrussell
authored andcommitted
fuzz: fix invalid pubkey error
pubkey_from_hexstr() was failing, which we didn't notice because we weren't checking the return value. The problem was that we were passing it a strlen that was half the actual length. Relevant error: [libsecp256k1] illegal argument: !secp256k1_fe_is_zero(&ge->x) ==417723== ERROR: libFuzzer: deadly signal #7 0x7f5deaacc7fb in abort #8 0x51b0b0 in secp256k1_default_illegal_callback_fn secp256k1.c #9 0x51bd8e in secp256k1_ec_pubkey_serialize #10 0x4e235b in pubkey_to_der bitcoin/pubkey.c:29:7 #11 0x4e2941 in pubkey_cmp bitcoin/pubkey.c:89:2 #12 0x4e333d in bitcoin_redeem_2of2 bitcoin/script.c:144:6 #13 0x4f1396 in run tests/fuzz/fuzz-close_tx.c:78:19
1 parent 61b0634 commit 5ea1fad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/fuzz/fuzz-close_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ void run(const uint8_t *data, size_t size)
7171
/* We assert it's valid, so we can't throw garbage at the funding script.. */
7272
pk1 = tal(tmpctx, struct pubkey);
7373
pk2 = tal(tmpctx, struct pubkey);
74-
pubkey_from_hexstr("034fede2c619f647fe7c01d40ae22e4c285291ca2ffb47937bbfb7d6e8285a081f",
75-
PUBKEY_CMPR_LEN, pk1);
76-
pubkey_from_hexstr("028dfe31019dd61fa04c76ad065410e5d063ac2949c04c14b214c1b363e517452f",
77-
PUBKEY_CMPR_LEN, pk2);
74+
assert(pubkey_from_hexstr("034fede2c619f647fe7c01d40ae22e4c285291ca2ffb47937bbfb7d6e8285a081f",
75+
2 * PUBKEY_CMPR_LEN, pk1));
76+
assert(pubkey_from_hexstr("028dfe31019dd61fa04c76ad065410e5d063ac2949c04c14b214c1b363e517452f",
77+
2 * PUBKEY_CMPR_LEN, pk2));
7878
funding_script = bitcoin_redeem_2of2(tmpctx, pk1, pk2);
7979

8080
create_close_tx(tmpctx, chainparams, NULL, NULL, our_script,

0 commit comments

Comments
 (0)