[compiler-rt] r334510 - [Fuzzer] Afl driver changing iterations handling
David Carlier via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 08:47:58 PDT 2018
Author: devnexen
Date: Tue Jun 12 08:47:58 2018
New Revision: 334510
URL: http://llvm.org/viewvc/llvm-project?rev=334510&view=rev
Log:
[Fuzzer] Afl driver changing iterations handling
Handling differently the iterations with the type limit and eventually an error message.
Reviewers: morehouse, kcc
Reviewed By: morehouse
Differential Revision: https://reviews.llvm.org/D47880
Modified:
compiler-rt/trunk/lib/fuzzer/afl/afl_driver.cpp
compiler-rt/trunk/test/fuzzer/afl-driver.test
Modified: compiler-rt/trunk/lib/fuzzer/afl/afl_driver.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/afl/afl_driver.cpp?rev=334510&r1=334509&r2=334510&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/afl/afl_driver.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/afl/afl_driver.cpp Tue Jun 12 08:47:58 2018
@@ -59,6 +59,7 @@ statistics from the file. If that fails
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
+#include <limits.h>
#include <fstream>
#include <iostream>
@@ -305,6 +306,18 @@ int ExecuteFilesOnyByOne(int argc, char
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",
+ arg);
+ ::exit(-1);
+ }
+
+ *N = static_cast<int>(NL);
+}
+
int main(int argc, char **argv) {
fprintf(stderr,
"======================= INFO =========================\n"
@@ -331,11 +344,12 @@ int main(int argc, char **argv) {
int N = 1000;
if (argc == 2 && argv[1][0] == '-')
- N = atoi(argv[1] + 1);
- else if(argc == 2 && (N = atoi(argv[1])) > 0)
- fprintf(stderr, "WARNING: using the deprecated call style `%s %d`\n",
- argv[0], N);
- else if (argc > 1)
+ set_iterations(&N, argv[1] + 1);
+ else if(argc == 2) {
+ fprintf(stderr, "WARNING: using the deprecated call style `%s %d`\n",
+ argv[0], N);
+ set_iterations(&N, argv[1]);
+ } else if (argc > 1)
return ExecuteFilesOnyByOne(argc, argv);
assert(N > 0);
Modified: compiler-rt/trunk/test/fuzzer/afl-driver.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/afl-driver.test?rev=334510&r1=334509&r2=334510&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/afl-driver.test (original)
+++ compiler-rt/trunk/test/fuzzer/afl-driver.test Tue Jun 12 08:47:58 2018
@@ -21,9 +21,16 @@ CHECK3: __afl_persistent_loop calle, Cou
CHECK3: LLVMFuzzerTestOneInput called; Size = 3
-RUN: %run %t-AFLDriverTest %t.file3 2>&1 | FileCheck %s --check-prefix=CHECK4
-CHECK4: LLVMFuzzerTestOneInput called; Size = 3
+RUN: not %run %t-AFLDriverTest %t.file3 2>&1 | FileCheck %s --check-prefix=CHECK4
+CHECK4: WARNING: using the deprecated call style `{{.*}} 1000`
+CHECK4: WARNING: iterations invalid `{{.*}}`
RUN: %run %t-AFLDriverTest %t.file3 %t.file4 2>&1 | FileCheck %s --check-prefix=CHECK5
CHECK5: LLVMFuzzerTestOneInput called; Size = 3
CHECK5: LLVMFuzzerTestOneInput called; Size = 4
+
+RUN: not %run %t-AFLDriverTest < %t.file3 --1 2>&1 | FileCheck %s --check-prefix=CHECK6
+CHECK6: WARNING: iterations invalid `-1`
+
+RUN: not %run %t-AFLDriverTest < %t.file3 -Invalid 2>&1 | FileCheck %s --check-prefix=CHECK7
+CHECK7: WARNING: iterations invalid `Invalid`
More information about the llvm-commits
mailing list