about summary refs log tree commit diff
path: root/utils/afl_proxy/afl-proxy.c
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-04-30 23:41:06 +0200
committervanhauser-thc <vh@thc.org>2021-04-30 23:41:06 +0200
commit86452cc959bd4b0d5fe6e60d0eefbc7848fe38e2 (patch)
tree4828130832f7fd531cdacc2887f2da636fdcc9c0 /utils/afl_proxy/afl-proxy.c
parentf4cc718fdc4571f56280a1efad3645125bee2154 (diff)
downloadafl++-86452cc959bd4b0d5fe6e60d0eefbc7848fe38e2.tar.gz
fix stdin trimming
Diffstat (limited to 'utils/afl_proxy/afl-proxy.c')
-rw-r--r--utils/afl_proxy/afl-proxy.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/utils/afl_proxy/afl-proxy.c b/utils/afl_proxy/afl-proxy.c
index 2d8ba991..6006e238 100644
--- a/utils/afl_proxy/afl-proxy.c
+++ b/utils/afl_proxy/afl-proxy.c
@@ -195,10 +195,7 @@ static u32 __afl_next_testcase(u8 *buf, u32 max_len) {
   /* report that we are starting the target */
   if (write(FORKSRV_FD + 1, &res, 4) != 4) return 0;
 
-  if (status < 1)
-    return 0;
-  else
-    return status;
+  return status;
 
 }
 
@@ -216,7 +213,7 @@ int main(int argc, char *argv[]) {
 
   /* This is were the testcase data is written into */
   u8  buf[1024];  // this is the maximum size for a test case! set it!
-  u32 len;
+  s32 len;
 
   /* here you specify the map size you need that you are reporting to
      afl-fuzz.  Any value is fine as long as it can be divided by 32. */
@@ -228,10 +225,20 @@ int main(int argc, char *argv[]) {
 
   while ((len = __afl_next_testcase(buf, sizeof(buf))) > 0) {
 
-    /* here you have to create the magic that feeds the buf/len to the
-       target and write the coverage to __afl_area_ptr */
+    if (len > 4) {  // the minimum data size you need for the target
 
-    // ... the magic ...
+      /* here you have to create the magic that feeds the buf/len to the
+         target and write the coverage to __afl_area_ptr */
+
+      // ... the magic ...
+
+      // remove this, this is just to make afl-fuzz not complain when run
+      if (buf[0] == 0xff)
+        __afl_area_ptr[1] = 1;
+      else
+        __afl_area_ptr[2] = 2;
+
+    }
 
     /* report the test case is done and wait for the next */
     __afl_end_testcase();