Skip to content

Commit 07527d9

Browse files
morehouserustyrussell
authored andcommitted
fuzz: avoid buffer overflow in bech32 target
If the fuzzer passes an empty data buffer, the fuzz target currently attempts to read from it. We should short-circuit instead.
1 parent df085a8 commit 07527d9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tests/fuzz/fuzz-bech32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ void run(const uint8_t *data, size_t size)
1919
int wit_version;
2020
bech32_encoding benc;
2121

22+
if (size < 1)
23+
return;
24+
2225
/* Buffer size is defined in each function's doc comment. */
2326
bech32_str = malloc(size + strlen(hrp_inv) + 8);
2427
benc = data[0] ? BECH32_ENCODING_BECH32 : BECH32_ENCODING_BECH32M;

0 commit comments

Comments
 (0)