about summary refs log tree commit diff
path: root/src/afl-fuzz.c
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2019-12-25 10:35:49 +0100
committerAndrea Fioraldi <andreafioraldi@gmail.com>2019-12-25 10:35:49 +0100
commit9ed4bfbca86ee6ff923e47deca0ebd5ae7a08b77 (patch)
treedb4bed50fdfa837afe829b1ef4b0655e3a3cfe9d /src/afl-fuzz.c
parent67b6298895e8db0cc91c3bbd0bc29c48f8572c2e (diff)
downloadafl++-9ed4bfbca86ee6ff923e47deca0ebd5ae7a08b77.tar.gz
AFL_PRELOAD -> QEMU_SET_ENV for afl-fuzz,afl-showmap,afl-analyze,afl-tmin
Diffstat (limited to 'src/afl-fuzz.c')
-rw-r--r--src/afl-fuzz.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 54fdcc25..7df82b12 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -714,21 +714,24 @@ int main(int argc, char** argv) {
 
     if (qemu_mode) {
 
-      char* qemu_preload = getenv("QEMU_SET_ENV");
-      char  buf[4096];
-
-      if (qemu_preload) {
-
-        snprintf(buf, sizeof(buf), "%s,LD_PRELOAD=%s", qemu_preload,
-                 getenv("AFL_PRELOAD"));
-
-      } else {
-
-        snprintf(buf, sizeof(buf), "LD_PRELOAD=%s", getenv("AFL_PRELOAD"));
-
+      u8* qemu_preload = getenv("QEMU_SET_ENV");
+      u8* afl_preload = getenv("AFL_PRELOAD");
+      u8* buf;
+      
+      s32 i, afl_preload_size = strlen(afl_preload);
+      for (i = 0; i < afl_preload_size; ++i) {
+        if (afl_preload[i] == ',')
+          PFATAL("Comma (',') is not allowed in AFL_PRELOAD when -Q is specified!");
       }
 
+      if (qemu_preload)
+        buf = alloc_printf("%s,LD_PRELOAD=%s", qemu_preload, afl_preload);
+      else
+        buf = alloc_printf("LD_PRELOAD=%s", afl_preload);
+
       setenv("QEMU_SET_ENV", buf, 1);
+      
+      ck_free(buf);
 
     } else {