fuzzers: ignore size limits when compiled standalone

This way we can still call fuzzers on old samples, but oss-fuzz will not waste
its and our time finding overly large inputs.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-05-12 14:57:07 +02:00
parent 7593691aad
commit c4f883b78e
21 changed files with 37 additions and 19 deletions
+12
View File
@@ -4,6 +4,7 @@
#include <stddef.h>
#include <stdint.h>
#include "env-util.h"
#include "fileio.h"
/* The entry point into the fuzzer */
@@ -15,3 +16,14 @@ static inline FILE* data_to_file(const uint8_t *data, size_t size) {
else
return fmemopen_unlocked((char*) data, size, "re");
}
/* Check if we are within the specified size range.
* The upper limit is ignored if FUZZ_USE_SIZE_LIMIT is unset.
*/
static inline bool outside_size_range(size_t size, size_t lower, size_t upper) {
if (size < lower)
return true;
if (size > upper)
return FUZZ_USE_SIZE_LIMIT;
return false;
}