Skip to content

Commit 54645e8

Browse files
[libc] Fix issue with fuzz input too short for atoi diff fuzz
The string to integer differential fuzzer assumes at least one byte of meaningful input, but wasn't explicitly checking that. Now it does.
1 parent 5843ffb commit 54645e8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libc/fuzzing/stdlib/strtointeger_differential_fuzz.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
// greater than 50% chance for each character to end the string, making the odds
4545
// of getting long numbers very low.
4646
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
47+
if (size < 2) // Needs at least one byte for the base and one byte for the
48+
// string.
49+
return 0;
50+
4751
uint8_t *container = new uint8_t[size + 1];
4852
if (!container)
4953
__builtin_trap();

0 commit comments

Comments
 (0)