about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-06-24 11:09:33 +0200
committervan Hauser <vh@thc.org>2020-06-24 11:09:33 +0200
commitbdc8e3b79e8fd4b59ef71a9f585fe8590b90f1c2 (patch)
tree18ddbac0f136225dee156c0cc94dd791496e21f1 /src
parent9289af040c25a9c426cc2a275596d8a009aee894 (diff)
downloadafl++-bdc8e3b79e8fd4b59ef71a9f585fe8590b90f1c2.tar.gz
create .synced/NAMES.last to document last sync attempts
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-run.c11
-rw-r--r--src/afl-fuzz.c4
2 files changed, 10 insertions, 5 deletions
diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c
index eb562c60..432d0195 100644
--- a/src/afl-fuzz-run.c
+++ b/src/afl-fuzz-run.c
@@ -466,6 +466,12 @@ void sync_fuzzers(afl_state_t *afl) {
 
     synced++;
 
+    /* document the attempt to sync to this instance */
+
+    sprintf(qd_synced_path, "%s/.synced/%s.last", afl->out_dir, sd_ent->d_name);
+    id_fd = open(qd_synced_path, O_RDWR | O_CREAT | O_TRUNC, 0600);
+    if (id_fd >= 0) close(id_fd);
+
     /* Skip anything that doesn't have a queue/ subdirectory. */
 
     sprintf(qd_path, "%s/%s/queue", afl->sync_dir, sd_ent->d_name);
@@ -490,14 +496,13 @@ void sync_fuzzers(afl_state_t *afl) {
 
     if (id_fd < 0) { PFATAL("Unable to create '%s'", qd_synced_path); }
 
-    if (read(id_fd, &min_accept, sizeof(u32)) > 0) {
+    if (read(id_fd, &min_accept, sizeof(u32)) == sizeof(u32)) {
 
+      next_min_accept = min_accept;
       lseek(id_fd, 0, SEEK_SET);
 
     }
 
-    next_min_accept = min_accept;
-
     /* Show stats */
 
     snprintf(afl->stage_name_buf, STAGE_BUF_SIZE, "sync %u", ++sync_cnt);
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index c8083f71..f3b63ff0 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -384,7 +384,7 @@ int main(int argc, char **argv_orig, char **envp) {
         afl->out_dir = optarg;
         break;
 
-      case 'M': {                                         /* master sync ID */
+      case 'M': {                                           /* main sync ID */
 
         u8 *c;
 
@@ -413,7 +413,7 @@ int main(int argc, char **argv_orig, char **envp) {
 
       break;
 
-      case 'S':
+      case 'S':                                        /* secondary sync id */
 
         if (afl->sync_id) { FATAL("Multiple -S or -M options not supported"); }
         afl->sync_id = ck_strdup(optarg);