aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-09 12:35:52 +0200
committervan Hauser <vh@thc.org>2020-08-09 12:35:52 +0200
commit32db31b5550b73cbb20abb5e862fb08f86681ace (patch)
treed29b57f101dc8443a8f2e5d2829e84065bd2241d
parenta1129b67c22ff54e25d457efbe44b3ab11851b5b (diff)
downloadafl++-32db31b5550b73cbb20abb5e862fb08f86681ace.tar.gz
fixes
-rw-r--r--include/afl-fuzz.h3
-rw-r--r--src/afl-fuzz-bitmap.c1
-rw-r--r--src/afl-fuzz-run.c6
-rw-r--r--src/afl-fuzz-state.c30
-rw-r--r--src/afl-fuzz.c6
5 files changed, 28 insertions, 18 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index 5e4e5a19..328c8405 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -838,7 +838,8 @@ struct custom_mutator {
};
-void afl_state_init(afl_state_t *, uint32_t map_size);
+void afl_state_init_1(afl_state_t *, uint32_t map_size);
+void afl_state_init_2(afl_state_t *, uint32_t map_size);
void afl_state_deinit(afl_state_t *);
/* Set stop_soon flag on all childs, kill all childs */
diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c
index 8aaa4ae1..11a3f121 100644
--- a/src/afl-fuzz-bitmap.c
+++ b/src/afl-fuzz-bitmap.c
@@ -257,7 +257,6 @@ u32 count_bytes_len(afl_state_t *afl, u8 *mem, u32 len) {
}
-
/* Count the number of non-255 bytes set in the bitmap. Used strictly for the
status screen, several calls per second or so. */
diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c
index b325f788..89ae0424 100644
--- a/src/afl-fuzz-run.c
+++ b/src/afl-fuzz-run.c
@@ -480,10 +480,10 @@ abort_calibration:
0) {
u32 len = q->len;
- if (len % 4)
- len = len + 4 - (q->len % 4);
+ if (len % 4) len = len + 4 - (q->len % 4);
u32 bytes = count_bytes_len(afl, afl->taint_fsrv.trace_bits, len);
- if (afl->debug) fprintf(stderr, "Debug: tainted bytes: %u\n", bytes);
+ if (afl->debug)
+ fprintf(stderr, "Debug: tainted %u out of %u bytes\n", bytes, q->len);
}
diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c
index e2d62bc6..aab785e1 100644
--- a/src/afl-fuzz-state.c
+++ b/src/afl-fuzz-state.c
@@ -75,7 +75,7 @@ static list_t afl_states = {.element_prealloc_count = 0};
/* Initializes an afl_state_t. */
-void afl_state_init(afl_state_t *afl, uint32_t map_size) {
+void afl_state_init_1(afl_state_t *afl, uint32_t map_size) {
/* thanks to this memset, growing vars like out_buf
and out_size are NULL/0 by default. */
@@ -100,16 +100,6 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) {
afl->cpu_aff = -1; /* Selected CPU core */
#endif /* HAVE_AFFINITY */
- afl->virgin_bits = ck_alloc(map_size);
- afl->virgin_tmout = ck_alloc(map_size);
- afl->virgin_crash = ck_alloc(map_size);
- afl->var_bytes = ck_alloc(map_size);
- afl->top_rated = ck_alloc(map_size * sizeof(void *));
- afl->clean_trace = ck_alloc(map_size);
- afl->clean_trace_custom = ck_alloc(map_size);
- afl->first_trace = ck_alloc(map_size);
- afl->map_tmp_buf = ck_alloc(map_size);
-
afl->fsrv.use_stdin = 1;
afl->fsrv.map_size = map_size;
afl->fsrv.function_opt = (u8 *)afl;
@@ -160,6 +150,24 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) {
}
+void afl_state_init_2(afl_state_t *afl, uint32_t map_size) {
+
+ afl->shm.map_size = map_size ? map_size : MAP_SIZE;
+
+ afl->virgin_bits = ck_alloc(map_size);
+ afl->virgin_tmout = ck_alloc(map_size);
+ afl->virgin_crash = ck_alloc(map_size);
+ afl->var_bytes = ck_alloc(map_size);
+ afl->top_rated = ck_alloc(map_size * sizeof(void *));
+ afl->clean_trace = ck_alloc(map_size);
+ afl->clean_trace_custom = ck_alloc(map_size);
+ afl->first_trace = ck_alloc(map_size);
+ afl->map_tmp_buf = ck_alloc(map_size);
+
+ afl->fsrv.map_size = map_size;
+
+}
+
/*This sets up the environment variables for afl-fuzz into the afl_state
* struct*/
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 4a3d2e97..93ab90e2 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -262,7 +262,7 @@ int main(int argc, char **argv_orig, char **envp) {
if (get_afl_env("AFL_DEBUG")) { debug = afl->debug = 1; }
map_size = get_map_size();
- afl_state_init(afl, map_size);
+ afl_state_init_1(afl, map_size);
afl->debug = debug;
afl_fsrv_init(&afl->fsrv);
@@ -827,10 +827,12 @@ int main(int argc, char **argv_orig, char **envp) {
if (afl->fsrv.taint_mode && afl->fsrv.map_size < MAX_FILE) {
- afl->fsrv.map_size = afl->shm.map_size = MAX_FILE;
+ map_size = afl->fsrv.map_size = afl->shm.map_size = MAX_FILE;
}
+ afl_state_init_2(afl, map_size);
+
if (!mem_limit_given && afl->shm.cmplog_mode) afl->fsrv.mem_limit += 260;
OKF("afl++ is maintained by Marc \"van Hauser\" Heuse, Heiko \"hexcoder\" "