Index: lib/fuzzer/afl/afl_driver.cpp =================================================================== --- lib/fuzzer/afl/afl_driver.cpp +++ lib/fuzzer/afl/afl_driver.cpp @@ -305,6 +305,18 @@ return 0; } +static void set_iterations(int *N, const char *arg) { + char *next_char; + long NL = strtol(arg, &next_char, 10); + if (NL < 1 || NL > INT_MAX || *next_char != '\0') { + fprintf(stderr, "WARNING: iterations invalid `%s`\n", + next_char); + ::exit(-1); + } + + *N = static_cast(NL); +} + int main(int argc, char **argv) { fprintf(stderr, "======================= INFO =========================\n" @@ -331,11 +343,12 @@ int N = 1000; if (argc == 2 && argv[1][0] == '-') - N = atoi(argv[1] + 1); - else if(argc == 2 && (N = atoi(argv[1])) > 0) + set_iterations(&N, argv[1] + 1); + else if(argc == 2) { + set_iterations(&N, argv[1]); fprintf(stderr, "WARNING: using the deprecated call style `%s %d`\n", argv[0], N); - else if (argc > 1) + } else if (argc > 1) return ExecuteFilesOnyByOne(argc, argv); assert(N > 0);