diff options
author | van Hauser <vh@thc.org> | 2020-05-13 16:39:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 16:39:23 +0200 |
commit | c4fe6f5277a8edfbf12d9c9c5db77ceb5271bd7f (patch) | |
tree | c039c7192a3aa9f83ac9f7dde9c68dac01f3f607 /src/afl-fuzz-init.c | |
parent | f8b3d34225102158ed585130e3de08772e989b53 (diff) | |
parent | 645e331559d01d234be231a7f5076c2ad658b159 (diff) | |
download | afl++-c4fe6f5277a8edfbf12d9c9c5db77ceb5271bd7f.tar.gz |
Merge pull request #361 from rish9101/pre_save_format
Add post library API as custom mutator and rename pre_save
Diffstat (limited to 'src/afl-fuzz-init.c')
-rw-r--r-- | src/afl-fuzz-init.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 78b92368..aea22f48 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -297,12 +297,16 @@ void setup_post(afl_state_t *afl) { dh = dlopen(fn, RTLD_NOW); if (!dh) { FATAL("%s", dlerror()); } - afl->post_handler = dlsym(dh, "afl_postprocess"); - if (!afl->post_handler) { FATAL("Symbol 'afl_postprocess' not found."); } - afl->post_init = dlsym(dh, "afl_postprocess_init"); - if (!afl->post_init) { FATAL("Symbol 'afl_postprocess_init' not found."); } - afl->post_deinit = dlsym(dh, "afl_postprocess_deinit"); - if (!afl->post_deinit) { + struct custom_mutator * mutator; + mutator = ck_alloc(sizeof(struct custom_mutator)); + memset(mutator, 0, sizeof(struct custom_mutator)); + + mutator->afl_custom_post_process = dlsym(dh, "afl_postprocess"); + if (!mutator->afl_custom_post_process) { FATAL("Symbol 'afl_postprocess' not found."); } + mutator->afl_custom_init = dlsym(dh, "afl_postprocess_init"); + if (!mutator->afl_custom_init) { FATAL("Symbol 'afl_postprocess_init' not found."); } + mutator->afl_custom_deinit = dlsym(dh, "afl_postprocess_deinit"); + if (!mutator->afl_custom_post_process) { FATAL("Symbol 'afl_postprocess_deinit' not found."); @@ -310,16 +314,10 @@ void setup_post(afl_state_t *afl) { /* Do a quick test. It's better to segfault now than later =) */ - u8 *post_buf = NULL; - afl->post_data = afl->post_init(afl); - if (!afl->post_data) { FATAL("Could not initialize post handler."); } - - size_t post_len = afl->post_handler(afl->post_data, tbuf, tlen, &post_buf); - if (!post_len || !post_buf) { + mutator->data = mutator->afl_custom_init(afl, rand_below(afl, 0xFFFFFFFF)); + if (!mutator->data) { FATAL("Could not initialize post handler."); } - SAYF("Empty return in test post handler for buf=\"hello\\0\"."); - - } + afl->post_library_mutator = mutator; OKF("Postprocessor installed successfully."); |