fuzz: limit input length (#238)

Longer inputs can lead to timeouts on oss-fuzz
This commit is contained in:
Randy 2022-05-06 03:49:11 +02:00 committed by GitHub
parent f0b370716b
commit 39dbf507d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,9 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{ {
if(size < 1) return 0; if(size < 1) return 0;
/* Avoid timeout with long inputs */
if(size > (64 * 1024)) return 0;
if(data[size-1] != '\0') return 0; if(data[size-1] != '\0') return 0;
const uint8_t* ptr = data; const uint8_t* ptr = data;
@ -54,7 +57,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
options = UTF8PROC_STRIPCC; options = UTF8PROC_STRIPCC;
memcpy(copy, data, size); memcpy(copy, data, size);
utf8proc_normalize_utf32(copy, size, options); utf8proc_normalize_utf32(copy, size, options);
options = 0; options = 0;
memcpy(copy, data, size); memcpy(copy, data, size);
utf8proc_normalize_utf32(copy, size, options); utf8proc_normalize_utf32(copy, size, options);