about summary refs log tree commit diff
path: root/src/afl-fuzz-init.c
diff options
context:
space:
mode:
authorh1994st <h1994st@gmail.com>2020-03-02 15:27:31 -0500
committerh1994st <h1994st@gmail.com>2020-03-02 15:27:31 -0500
commit031946136bb61990d03d7cc4ebc9487218b30338 (patch)
tree37f27b4f0a84da70f3e0decddd16639217c936b9 /src/afl-fuzz-init.c
parent7b59e05600aff4e9deb3110887d6ad49838f02b0 (diff)
parentf6050ab804f06fbedfb1fd1b619217be85db2e00 (diff)
downloadafl++-031946136bb61990d03d7cc4ebc9487218b30338.tar.gz
Merge branch 'master' of https://github.com/vanhauser-thc/AFLplusplus
Diffstat (limited to 'src/afl-fuzz-init.c')
-rw-r--r--src/afl-fuzz-init.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index 9ae95b7d..08b6de60 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -866,7 +866,7 @@ void find_timeout(void) {
 
 }
 
-/* A helper function for maybe_delete_out_dir(), deleting all prefixed
+/* A helper function for handle_existing_out_dir(), deleting all prefixed
    files in a directory. */
 
 static u8 delete_files(u8* path, u8* prefix) {
@@ -990,9 +990,10 @@ dir_cleanup_failed:
 }
 
 /* Delete fuzzer output directory if we recognize it as ours, if the fuzzer
-   is not currently running, and if the last run time isn't too great. */
+   is not currently running, and if the last run time isn't too great. 
+   Resume fuzzing if `-` is set as in_dir or if AFL_AUTORESUME is set */
 
-void maybe_delete_out_dir(void) {
+static void handle_existing_out_dir(void) {
 
   FILE* f;
   u8*   fn = alloc_printf("%s/fuzzer_stats", out_dir);
@@ -1035,6 +1036,15 @@ void maybe_delete_out_dir(void) {
 
     fclose(f);
 
+    /* Autoresume treats a normal run as in_place_resume if a valid out dir already exists */
+
+    if (!in_place_resume && autoresume) {
+    
+      OKF("Detected prior run with AFL_AUTORESUME set. Resuming.");
+      in_place_resume = 1;
+
+    }
+
     /* Let's see how much work is at stake. */
 
     if (!in_place_resume && last_update - start_time2 > OUTPUT_GRACE * 60) {
@@ -1051,7 +1061,7 @@ void maybe_delete_out_dir(void) {
            "    or specify a different output location for this job. To resume "
            "the old\n"
            "    session, put '-' as the input directory in the command line "
-           "('-i -') and\n"
+           "('-i -') or set the AFL_AUTORESUME=1 env variable and\n"
            "    try again.\n",
            OUTPUT_GRACE);
 
@@ -1278,7 +1288,7 @@ void setup_dirs_fds(void) {
 
     if (errno != EEXIST) PFATAL("Unable to create '%s'", out_dir);
 
-    maybe_delete_out_dir();
+    handle_existing_out_dir();
 
   } else {