Created
April 18, 2020 19:07
-
-
Save pldubouilh/42e114a430da25878d6739d11f0c86a5 to your computer and use it in GitHub Desktop.
clang fuzzing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
// clang -O0 -Wall -g -fsanitize=fuzzer fuzzer.c && ./a.out | |
int LLVMFuzzerTestOneInput(const char *Data, size_t Size) | |
{ | |
int maxlen = (int) Size; | |
const char *start = Data; | |
char *end, *aaa; | |
int len; | |
while (maxlen > 0) { | |
end = memchr(start, '\0', maxlen); | |
aaa = memchr(start, 'a', maxlen); | |
if (aaa == NULL || end == NULL) { | |
return 1; | |
} | |
len = end - aaa; | |
if (len <= 0) { | |
return 1; | |
} | |
maxlen -= (end - start) + 1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment