mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
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.
This commit is contained in:
committed by
Rusty Russell
parent
df085a8a87
commit
07527d9fbb
@@ -19,6 +19,9 @@ void run(const uint8_t *data, size_t size)
|
||||
int wit_version;
|
||||
bech32_encoding benc;
|
||||
|
||||
if (size < 1)
|
||||
return;
|
||||
|
||||
/* Buffer size is defined in each function's doc comment. */
|
||||
bech32_str = malloc(size + strlen(hrp_inv) + 8);
|
||||
benc = data[0] ? BECH32_ENCODING_BECH32 : BECH32_ENCODING_BECH32M;
|
||||
|
||||
Reference in New Issue
Block a user