about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index eeb660f7..a9a6db97 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -113,7 +113,8 @@ static void usage(u8* argv0) {
       "                  pacemaker mode (minutes of no new paths, 0 = "
       "immediately).\n"
       "                  a recommended value is 10-60. see docs/README.MOpt\n"
-      "  -c program    - enable CmpLog by specifying a binary compiled for it.\n"
+      "  -c program    - enable CmpLog by specifying a binary compiled for "
+      "it.\n"
       "                  if using QEMU, just use -c 0.\n\n"
 
       "Fuzzing behavior settings:\n"
@@ -654,25 +655,6 @@ int main(int argc, char** argv, char** envp) {
   if (!strcmp(in_dir, out_dir))
     FATAL("Input and output directories can't be the same");
 
-  if ((tmp_dir = getenv("AFL_TMPDIR")) != NULL) {
-
-    char tmpfile[file_extension 
-         ? strlen(tmp_dir) + 1 + 10 + 1 + strlen(file_extension) + 1
-         : strlen(tmp_dir) + 1 + 10 + 1];
-    if (file_extension) {
-      sprintf(tmpfile, "%s/.cur_input.%s", tmp_dir, file_extension);
-    } else {
-      sprintf(tmpfile, "%s/.cur_input", tmp_dir);
-    }
-    if (access(tmpfile, F_OK) !=
-        -1)  // there is still a race condition here, but well ...
-      FATAL("AFL_TMPDIR already has an existing temporary input file: %s",
-            tmpfile);
-
-  } else
-
-    tmp_dir = out_dir;
-
   if (dumb_mode) {
 
     if (crash_mode) FATAL("-C and -n are mutually exclusive");
@@ -846,6 +828,32 @@ int main(int argc, char** argv, char** envp) {
 
   if (!timeout_given) find_timeout();
 
+  if ((tmp_dir = getenv("AFL_TMPDIR")) != NULL && !in_place_resume) {
+
+    char tmpfile[file_extension
+                     ? strlen(tmp_dir) + 1 + 10 + 1 + strlen(file_extension) + 1
+                     : strlen(tmp_dir) + 1 + 10 + 1];
+    if (file_extension) {
+
+      sprintf(tmpfile, "%s/.cur_input.%s", tmp_dir, file_extension);
+
+    } else {
+
+      sprintf(tmpfile, "%s/.cur_input", tmp_dir);
+
+    }
+
+    if (access(tmpfile, F_OK) !=
+        -1)  // there is still a race condition here, but well ...
+      FATAL(
+          "AFL_TMPDIR already has an existing temporary input file: %s - if "
+          "this is not from another instance, then just remove the file.",
+          tmpfile);
+
+  } else
+
+    tmp_dir = out_dir;
+
   /* If we don't have a file name chosen yet, use a safe default. */
 
   if (!out_file) {
@@ -883,11 +891,13 @@ int main(int argc, char** argv, char** envp) {
   if (!out_file) setup_stdio_file();
 
   if (cmplog_binary) {
+
     if (unicorn_mode)
       FATAL("CmpLog and Unicorn mode are not compatible at the moment, sorry");
-    if (!qemu_mode)
-      check_binary(cmplog_binary);
+    if (!qemu_mode) check_binary(cmplog_binary);
+
   }
+
   check_binary(argv[optind]);
 
   start_time = get_cur_time();