Skip to content

Commit

Permalink
add limit to str size to increase chances of insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed May 1, 2024
1 parent d632fba commit 6b6f64a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libc/fuzzing/__support/hashtable_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *data, size_t size,
return i;
// skip the action byte
++i;
// create a limit of string size such that there can be more insertions
size_t limit = max_size < i + 256 ? max_size : i + 256;
// skip the null-terminated string
while (i < max_size && data[i] != 0)
while (i < limit && data[i] != 0)
++i;
// in the case the string is not null-terminated, null-terminate it
if (i == max_size && data[i - 1] != 0)
if (i == limit && data[i - 1] != 0)
data[i - 1] = 0;
break;
}
Expand Down

0 comments on commit 6b6f64a

Please sign in to comment.