Skip to content

Commit

Permalink
fuzz: set minimum bolt11 size to 9
Browse files Browse the repository at this point in the history
This prevents a buffer overflow in the custom mutator that can occur
when data_maxlen is 0.
  • Loading branch information
morehouse authored and rustyrussell committed Oct 24, 2023
1 parent dfe207d commit 58f16c2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/fuzz/fuzz-bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ static size_t initial_input(uint8_t *fuzz_data, size_t size, size_t max_size)
size_t LLVMFuzzerCustomMutator(uint8_t *fuzz_data, size_t size, size_t max_size,
unsigned int seed)
{
if (size < 8)
// A minimum size of 9 prevents hrp_maxlen <= 0 and data_maxlen <= 0.
if (size < 9)
return initial_input(fuzz_data, size, max_size);

// Interpret fuzz input as string (ensure it's null terminated).
Expand Down

0 comments on commit 58f16c2

Please sign in to comment.