about summary refs log tree commit diff
path: root/examples/aflpp_driver/aflpp_driver.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-06 18:44:12 +0200
committervan Hauser <vh@thc.org>2020-08-06 18:44:12 +0200
commit08bcaa135f6fc9282a947e1c73ef0866cb4cf2d0 (patch)
tree73d58ee0acef3fc0f1752916ec0e95628b7c6971 /examples/aflpp_driver/aflpp_driver.c
parente7f27702757ac922978a4ccbdc5feeafbf902591 (diff)
downloadafl++-08bcaa135f6fc9282a947e1c73ef0866cb4cf2d0.tar.gz
dummy mem test
Diffstat (limited to 'examples/aflpp_driver/aflpp_driver.c')
-rw-r--r--examples/aflpp_driver/aflpp_driver.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/aflpp_driver/aflpp_driver.c b/examples/aflpp_driver/aflpp_driver.c
index 86c7a69f..eab6b52c 100644
--- a/examples/aflpp_driver/aflpp_driver.c
+++ b/examples/aflpp_driver/aflpp_driver.c
@@ -56,6 +56,7 @@ If 1, close stdout at startup. If 2 close stderr; if 3 close both.
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <sys/mman.h>
 
 #include "config.h"
 
@@ -101,6 +102,7 @@ If 1, close stdout at startup. If 2 close stderr; if 3 close both.
 int                   __afl_sharedmem_fuzzing = 1;
 extern unsigned int * __afl_fuzz_len;
 extern unsigned char *__afl_fuzz_ptr;
+extern unsigned char *__afl_area_ptr;
 
 // libFuzzer interface is thin, so we don't include any libFuzzer headers.
 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
@@ -240,6 +242,10 @@ static int ExecuteFilesOnyByOne(int argc, char **argv) {
 
 int main(int argc, char **argv) {
 
+  uint8_t *dummy = (uint8_t*) mmap((void *)0x1000,250000, PROT_READ | PROT_WRITE,
+             MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+  __afl_area_ptr = dummy;
+
   printf(
       "======================= INFO =========================\n"
       "This binary is built for AFL-fuzz.\n"
@@ -275,6 +281,7 @@ int main(int argc, char **argv) {
     //    if (!getenv("AFL_DRIVER_DONT_DEFER")) {
 
     __afl_sharedmem_fuzzing = 0;
+    munmap(dummy, 256000);
     __afl_manual_init();
     //    }
     return ExecuteFilesOnyByOne(argc, argv);
@@ -285,6 +292,7 @@ int main(int argc, char **argv) {
   assert(N > 0);
 
   //  if (!getenv("AFL_DRIVER_DONT_DEFER"))
+  munmap(dummy, 256000);
   __afl_manual_init();
 
   // Call LLVMFuzzerTestOneInput here so that coverage caused by initialization