mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 04:18:06 +00:00
Merge pull request #1711 from atnwalk/atnwalk
AFL_POST_PROCESS_KEEP_ORIGINAL env variable for intermediate file formats and ATNwalk custom mutator
This commit is contained in:
@ -135,10 +135,19 @@ write_to_testcase(afl_state_t *afl, void **mem, u32 len, u32 fix) {
|
||||
|
||||
if (new_mem != *mem && new_mem != NULL && new_size > 0) {
|
||||
|
||||
u8 *new_buf = afl_realloc(AFL_BUF_PARAM(out_scratch), new_size);
|
||||
new_buf = afl_realloc(AFL_BUF_PARAM(out_scratch), new_size);
|
||||
if (unlikely(!new_buf)) { PFATAL("alloc"); }
|
||||
memcpy(new_buf, new_mem, new_size);
|
||||
|
||||
/* if AFL_POST_PROCESS_KEEP_ORIGINAL is set then save the original memory
|
||||
prior post-processing in new_mem to restore it later */
|
||||
if (unlikely(afl->afl_env.afl_post_process_keep_original)) {
|
||||
|
||||
new_mem = *mem;
|
||||
|
||||
}
|
||||
|
||||
*mem = new_buf;
|
||||
memcpy(*mem, new_mem, new_size);
|
||||
afl_swap_bufs(AFL_BUF_PARAM(out), AFL_BUF_PARAM(out_scratch));
|
||||
|
||||
}
|
||||
@ -162,7 +171,18 @@ write_to_testcase(afl_state_t *afl, void **mem, u32 len, u32 fix) {
|
||||
|
||||
/* everything as planned. use the potentially new data. */
|
||||
afl_fsrv_write_to_testcase(&afl->fsrv, *mem, new_size);
|
||||
len = new_size;
|
||||
|
||||
if (likely(!afl->afl_env.afl_post_process_keep_original)) {
|
||||
|
||||
len = new_size;
|
||||
|
||||
} else {
|
||||
|
||||
/* restore the original memory which was saved in new_mem */
|
||||
*mem = new_mem;
|
||||
afl_swap_bufs(AFL_BUF_PARAM(out), AFL_BUF_PARAM(out_scratch));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -394,6 +394,13 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
|
||||
afl->afl_env.afl_statsd =
|
||||
get_afl_env(afl_environment_variables[i]) ? 1 : 0;
|
||||
|
||||
} else if (!strncmp(env, "AFL_POST_PROCESS_KEEP_ORIGINAL",
|
||||
|
||||
afl_environment_variable_len)) {
|
||||
|
||||
afl->afl_env.afl_post_process_keep_original =
|
||||
get_afl_env(afl_environment_variables[i]) ? 1 : 0;
|
||||
|
||||
} else if (!strncmp(env, "AFL_TMPDIR",
|
||||
|
||||
afl_environment_variable_len)) {
|
||||
|
@ -292,6 +292,8 @@ static void usage(u8 *argv0, int more_help) {
|
||||
|
||||
PERSISTENT_MSG
|
||||
|
||||
"AFL_POST_PROCESS_KEEP_ORIGINAL: save the file as it was prior post-processing to the queue,\n"
|
||||
" but execute the post-processed one\n"
|
||||
"AFL_PRELOAD: LD_PRELOAD / DYLD_INSERT_LIBRARIES settings for target\n"
|
||||
"AFL_TARGET_ENV: pass extra environment variables to target\n"
|
||||
"AFL_SHUFFLE_QUEUE: reorder the input queue randomly on startup\n"
|
||||
|
Reference in New Issue
Block a user