about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-10-19 11:34:57 +0200
committervan Hauser <vh@thc.org>2020-10-19 11:34:57 +0200
commitac1c3b87015dd2c9b1bae0198f7925816aa63aec (patch)
tree43aacfca6123cea8fa2f4378c8aa2c189ca500dd /src/afl-fuzz.c
parentd8a058bf592a040256bb4b0a1ff9dcb97a8e3eda (diff)
downloadafl++-ac1c3b87015dd2c9b1bae0198f7925816aa63aec.tar.gz
mini improvements
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 9a82edeb..7215ecec 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -1378,10 +1378,9 @@ int main(int argc, char **argv_orig, char **envp) {
 
   u32 runs_in_current_cycle = (u32)-1;
   u32 prev_queued_paths = 0;
+  u8  skipped_fuzz;
 
-  while (1) {
-
-    u8 skipped_fuzz;
+  while (likely(!afl->stop_soon)) {
 
     cull_queue(afl);
 
@@ -1418,8 +1417,8 @@ int main(int argc, char **argv_orig, char **envp) {
       /* If we had a full queue cycle with no new finds, try
          recombination strategies next. */
 
-      if (afl->queued_paths == prev_queued &&
-          (get_cur_time() - afl->start_time) >= 3600) {
+      if (unlikely(afl->queued_paths == prev_queued &&
+                   (get_cur_time() - afl->start_time) >= 3600)) {
 
         if (afl->use_splicing) {
 
@@ -1534,46 +1533,49 @@ int main(int argc, char **argv_orig, char **envp) {
 
     }
 
-    if (likely(!afl->old_seed_selection)) {
+    ++runs_in_current_cycle;
 
-      ++runs_in_current_cycle;
-      if (unlikely(prev_queued_paths < afl->queued_paths)) {
+    do {
 
-        // we have new queue entries since the last run, recreate alias table
-        prev_queued_paths = afl->queued_paths;
-        create_alias_table(afl);
+      if (likely(!afl->old_seed_selection)) {
 
-      }
+        if (unlikely(prev_queued_paths < afl->queued_paths)) {
 
-      afl->current_entry = select_next_queue_entry(afl);
-      afl->queue_cur = afl->queue_buf[afl->current_entry];
+          // we have new queue entries since the last run, recreate alias table
+          prev_queued_paths = afl->queued_paths;
+          create_alias_table(afl);
 
-    }
+        }
 
-    skipped_fuzz = fuzz_one(afl);
+        afl->current_entry = select_next_queue_entry(afl);
+        afl->queue_cur = afl->queue_buf[afl->current_entry];
 
-    if (!skipped_fuzz && !afl->stop_soon && afl->sync_id) {
+      }
 
-      if (unlikely(afl->is_main_node)) {
+      skipped_fuzz = fuzz_one(afl);
 
-        if (!(sync_interval_cnt++ % (SYNC_INTERVAL / 3))) { sync_fuzzers(afl); }
+      if (unlikely(!afl->stop_soon && exit_1)) { afl->stop_soon = 2; }
 
-      } else {
+      if (unlikely(afl->old_seed_selection)) {
 
-        if (!(sync_interval_cnt++ % SYNC_INTERVAL)) { sync_fuzzers(afl); }
+        afl->queue_cur = afl->queue_cur->next;
+        ++afl->current_entry;
 
       }
 
-    }
+    } while (skipped_fuzz && afl->queue_cur && !afl->stop_soon);
 
-    if (!afl->stop_soon && exit_1) { afl->stop_soon = 2; }
+    if (!afl->stop_soon && afl->sync_id) {
 
-    if (afl->stop_soon) { break; }
+      if (unlikely(afl->is_main_node)) {
 
-    if (unlikely(afl->old_seed_selection)) {
+        if (!(sync_interval_cnt++ % (SYNC_INTERVAL / 3))) { sync_fuzzers(afl); }
 
-      afl->queue_cur = afl->queue_cur->next;
-      ++afl->current_entry;
+      } else {
+
+        if (!(sync_interval_cnt++ % SYNC_INTERVAL)) { sync_fuzzers(afl); }
+
+      }
 
     }