aboutsummaryrefslogtreecommitdiff
path: root/src/afl-analyze.c
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2020-04-17 11:01:20 +0200
committerDominik Maier <domenukk@gmail.com>2020-04-17 11:01:20 +0200
commit90ff345d733caa51f6d2895dd229104c286b62c4 (patch)
tree9bf965a3e7f447ea0779848a6e09f9b356a0707e /src/afl-analyze.c
parent8fa5d4c313372a337c7facf0428b0339babbe057 (diff)
parent2162fd8e1a1ceb745c1fcf87fb6a1053508591c4 (diff)
downloadafl++-90ff345d733caa51f6d2895dd229104c286b62c4.tar.gz
Merge branch 'dev' of github.com:aflplusplus/aflplusplus into dev
Diffstat (limited to 'src/afl-analyze.c')
-rw-r--r--src/afl-analyze.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/afl-analyze.c b/src/afl-analyze.c
index 6f946ed5..8a84b781 100644
--- a/src/afl-analyze.c
+++ b/src/afl-analyze.c
@@ -84,6 +84,7 @@ static volatile u8 stop_soon, /* Ctrl-C pressed? */
static u8 *target_path;
static u8 qemu_mode;
+static u32 map_size = MAP_SIZE;
/* Constants used for describing byte behavior. */
@@ -115,7 +116,7 @@ static u8 count_class_lookup[256] = {
static void classify_counts(u8 *mem) {
- u32 i = MAP_SIZE;
+ u32 i = map_size;
if (edges_only) {
@@ -144,7 +145,7 @@ static void classify_counts(u8 *mem) {
static inline u8 anything_set(void) {
u32 *ptr = (u32 *)trace_bits;
- u32 i = (MAP_SIZE >> 2);
+ u32 i = (map_size >> 2);
while (i--)
if (*(ptr++)) return 1;
@@ -217,7 +218,7 @@ static u32 analyze_run_target(char **argv, u8 *mem, u32 len, u8 first_run) {
s32 prog_in_fd;
u32 cksum;
- memset(trace_bits, 0, MAP_SIZE);
+ memset(trace_bits, 0, map_size);
MEM_BARRIER();
prog_in_fd = write_to_file(prog_in, mem, len);
@@ -311,7 +312,7 @@ static u32 analyze_run_target(char **argv, u8 *mem, u32 len, u8 first_run) {
}
- cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST);
+ cksum = hash32(trace_bits, map_size, HASH_CONST);
/* We don't actually care if the target is crashing or not,
except that when it does, the checksum should be different. */
@@ -795,8 +796,10 @@ static void usage(u8 *argv0) {
" (must contain abort_on_error=1 and symbolize=0)\n"
"MSAN_OPTIONS: custom settings for MSAN\n"
" (must contain exitcode="STRINGIFY(MSAN_ERROR)" and symbolize=0)\n"
- "AFL_PRELOAD: LD_PRELOAD / DYLD_INSERT_LIBRARIES settings for target\n"
"AFL_ANALYZE_HEX: print file offsets in hexadecimal instead of decimal\n"
+ "AFL_MAP_SIZE: the shared memory size for that target. must be >= the size\n"
+ " the target was compiled for\n"
+ "AFL_PRELOAD: LD_PRELOAD / DYLD_INSERT_LIBRARIES settings for target\n"
"AFL_SKIP_BIN_CHECK: skip checking the location of and the target\n"
, argv0, EXEC_TIMEOUT, MEM_LIMIT, doc_path);
@@ -811,7 +814,7 @@ int main(int argc, char **argv, char **envp) {
s32 opt;
u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0;
- char **use_argv;
+ char **use_argv, *ptr;
doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
@@ -931,12 +934,21 @@ int main(int argc, char **argv, char **envp) {
if (optind == argc || !in_file) usage(argv[0]);
+ 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);
+
+ }
+
use_hex_offsets = !!get_afl_env("AFL_ANALYZE_HEX");
check_environment_vars(envp);
sharedmem_t shm = {0};
- trace_bits = afl_shm_init(&shm, MAP_SIZE, 0);
+ trace_bits = afl_shm_init(&shm, map_size, 0);
atexit(at_exit_handler);
setup_signal_handlers();