[inih] remove fuzz blocker (#11949)

I learned a very important lesson after hours of debugging; that return
value does not influence the random data generator. Instead, it
influences the fuzzer core to accept the malformed data as corpus or
not.

Documentation
https://llvm.org/docs/LibFuzzer.html#rejecting-unwanted-inputs

Signed-off-by: Arjun <pkillarjun@protonmail.com>
This commit is contained in:
Arjun 2024-05-15 05:10:20 +05:30 committed by GitHub
parent f5a4f81fa2
commit 74d3bf3170
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 8 deletions

View File

@ -36,24 +36,26 @@ int dumper(void* user, const char* section, const char* name,
return 1;
}
extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
extern int
LLVMFuzzerTestOneInput(const char *data, size_t size)
{
char *data_in;
static int u = 100;
if (size < kMinInputLength || size > kMaxInputLength) {
return 0;
}
int e;
static int u = 100;
Prev_section[0] = '\0';
char *data_in = malloc(size + 1);
if (!data_in) return 0; // Just in case malloc fails
data_in = calloc((size + 1), sizeof(char));
if (!data_in) return 0;
memcpy(data_in, data, size);
data_in[size] = '\0';
e = ini_parse_string(data_in, dumper, &u);
ini_parse_string(data_in, dumper, &u);
free(data_in);
return e;
return 0;
}