This commit is contained in:
Maciej Domanski
2022-12-27 16:54:36 +01:00
parent 3d031f93a6
commit b189640a92
5 changed files with 45 additions and 27 deletions

View File

@ -16,6 +16,7 @@ __AFL_FUZZ_INIT();
one of the arguments.
*/
int main(int argc, char **argv) {
#ifdef __AFL_HAVE_MANUAL_CONTROL
__AFL_INIT();
#endif
@ -25,6 +26,7 @@ int main(int argc, char **argv) {
the loop and allowing the program to terminate. It protects against
accidental memory leaks and similar issues. */
while (__AFL_LOOP(100000)) {
int len = __AFL_FUZZ_TESTCASE_LEN;
// Check that the length of the test case is at least 8 bytes
@ -37,13 +39,20 @@ int main(int argc, char **argv) {
If so, call the "abort" function to terminate the program.
Otherwise, print an error message. */
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
if (strcmp(argv[2], "TEST2") == 0) { abort(); }
} else {
printf("Bad number of arguments!\n");
}
}
/* Exiting the loop allows the program to terminate normally. AFL will restart
the process with a clean slate for allocated memory, file descriptors, etc.
*/
return 0;
}
}