increase stack size
MODIFY
src/afl-common.c
src/afl-common.c
@@ -467,8 +467,8 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
u64 get_cur_time(void) {
- struct timeval tv;
- struct timezone tz;
+ static struct timeval tv;
+ static struct timezone tz;
gettimeofday(&tv, &tz);

MODIFY
src/afl-fuzz-run.c
src/afl-fuzz-run.c
@@ -885,7 +885,7 @@ u8 common_fuzz_stuff(afl_state_t *afl, u8 *out_buf, u32 len) {
u32 i, taint = 0;
for (i = 0; i < new_len; i++) {
- if (i > afl->taint_len || afl->taint_map[i] || i > afl->queue_cur->len)
+ if (i >= afl->taint_len || i >= afl->queue_cur->len || afl->taint_map[i])
new_buf[i] = out_buf[taint++];
else
new_buf[i] = afl->taint_src[i];

MODIFY
src/afl-fuzz.c
src/afl-fuzz.c
@@ -1305,6 +1305,12 @@ int main(int argc, char **argv_orig, char **envp) {
OKF("Taint forkserver successfully started");
+ const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb
+ struct rlimit rl;
+ rl.rlim_cur = kStackSize;
+ if (getrlimit(RLIMIT_STACK, &rl) != 0)
+ WARNF("Setting a higher stack size failed!");
+
#define BUF_PARAMS(name) (void **)&afl->name##_buf, &afl->name##_size
u8 *tmp1 = ck_maybe_grow(BUF_PARAMS(eff), MAX_FILE + 4096);
u8 *tmp2 = ck_maybe_grow(BUF_PARAMS(ex), MAX_FILE + 4096);
@@ -1312,7 +1318,6 @@ int main(int argc, char **argv_orig, char **envp) {
u8 *tmp4 = ck_maybe_grow(BUF_PARAMS(out), MAX_FILE + 4096);
u8 *tmp5 = ck_maybe_grow(BUF_PARAMS(out_scratch), MAX_FILE + 4096);
#undef BUF_PARAMS
-
if (!tmp1 || !tmp2 || !tmp3 || !tmp4 || !tmp5)
FATAL("memory issues. me hungry, feed me!");

increase stack size