[libc] Fix issue with fuzz input too short for atoi diff fuzz (#161705)

The string to integer differential fuzzer assumes at least one byte of
meaningful input, but wasn't explicitly checking that. Now it does.
This commit is contained in:
Michael Jones 2025-10-02 10:43:57 -07:00 committed by GitHub
parent 6bfa56a29a
commit c4709823bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,6 +44,10 @@
// greater than 50% chance for each character to end the string, making the odds
// of getting long numbers very low.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < 2) // Needs at least one byte for the base and one byte for the
// string.
return 0;
uint8_t *container = new uint8_t[size + 1];
if (!container)
__builtin_trap();