Skip to content

Commit 6b6f64a

Browse files
add limit to str size to increase chances of insertion
1 parent d632fba commit 6b6f64a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libc/fuzzing/__support/hashtable_fuzz.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *data, size_t size,
5050
return i;
5151
// skip the action byte
5252
++i;
53+
// create a limit of string size such that there can be more insertions
54+
size_t limit = max_size < i + 256 ? max_size : i + 256;
5355
// skip the null-terminated string
54-
while (i < max_size && data[i] != 0)
56+
while (i < limit && data[i] != 0)
5557
++i;
5658
// in the case the string is not null-terminated, null-terminate it
57-
if (i == max_size && data[i - 1] != 0)
59+
if (i == limit && data[i - 1] != 0)
5860
data[i - 1] = 0;
5961
break;
6062
}

0 commit comments

Comments
 (0)