about summary refs log tree commit diff
path: root/src/afl-common.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-17 11:56:08 +0200
committervan Hauser <vh@thc.org>2020-04-17 11:56:08 +0200
commit76e15a06957d03df7ffc8102a043c7694ba251d6 (patch)
tree00f939fb7ca175a009bfe44d7437f4936a3fcce7 /src/afl-common.c
parent1931838a112a23567b41ac0f018ae811ef7fbe1c (diff)
downloadafl++-76e15a06957d03df7ffc8102a043c7694ba251d6.tar.gz
refactoring getting the map size
Diffstat (limited to 'src/afl-common.c')
-rw-r--r--src/afl-common.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/afl-common.c b/src/afl-common.c
index 38c19234..2cbf1059 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -898,3 +898,21 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms,
 
 }
 
+u32 get_map_size() {
+
+  uint32_t map_size = MAP_SIZE;
+  char *   ptr;
+
+  if ((ptr = getenv("AFL_MAP_SIZE")) || (ptr = getenv("AFL_MAPSIZE"))) {
+
+    map_size = atoi(ptr);
+    if (map_size < 8 || map_size > (1 << 29))
+      FATAL("illegal AFL_MAP_SIZE %u, must be between 2^3 and 2^30", map_size);
+    if (map_size % 8) map_size = (((map_size >> 3) + 1) << 3);
+
+  }
+
+  return map_size;
+
+}
+