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 /examples | |
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 'examples')
-rw-r--r-- | examples/custom_mutators/example.c | 24 | ||||
-rw-r--r-- | examples/custom_mutators/example.py | 2 | ||||
-rw-r--r-- | examples/post_library/post_library.so.c | 2 | ||||
-rw-r--r-- | examples/post_library/post_library_png.so.c | 2 |
4 files changed, 15 insertions, 15 deletions
diff --git a/examples/custom_mutators/example.c b/examples/custom_mutators/example.c index c8200b26..c9be3e0c 100644 --- a/examples/custom_mutators/example.c +++ b/examples/custom_mutators/example.c @@ -38,7 +38,7 @@ typedef struct my_mutator { BUF_VAR(u8, data); BUF_VAR(u8, havoc); BUF_VAR(u8, trim); - BUF_VAR(u8, pre_save); + BUF_VAR(u8, post_process); } my_mutator_t; @@ -139,11 +139,11 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size, * @return Size of the output buffer after processing or the needed amount. * A return of 0 indicates an error. */ -size_t afl_custom_pre_save(my_mutator_t *data, uint8_t *buf, size_t buf_size, +size_t afl_custom_post_process(my_mutator_t *data, uint8_t *buf, size_t buf_size, uint8_t **out_buf) { - uint8_t *pre_save_buf = maybe_grow(BUF_PARAMS(data, pre_save), buf_size + 5); - if (!pre_save_buf) { + uint8_t *post_process_buf = maybe_grow(BUF_PARAMS(data, post_process), buf_size + 5); + if (!post_process_buf) { perror("custom mutator realloc failed."); *out_buf = NULL; @@ -151,14 +151,14 @@ size_t afl_custom_pre_save(my_mutator_t *data, uint8_t *buf, size_t buf_size, } - memcpy(pre_save_buf + 5, buf, buf_size); - pre_save_buf[0] = 'A'; - pre_save_buf[1] = 'F'; - pre_save_buf[2] = 'L'; - pre_save_buf[3] = '+'; - pre_save_buf[4] = '+'; + memcpy(post_process_buf + 5, buf, buf_size); + post_process_buf[0] = 'A'; + post_process_buf[1] = 'F'; + post_process_buf[2] = 'L'; + post_process_buf[3] = '+'; + post_process_buf[4] = '+'; - *out_buf = pre_save_buf; + *out_buf = post_process_buf; return buf_size + 5; @@ -364,7 +364,7 @@ void afl_custom_queue_new_entry(my_mutator_t * data, */ void afl_custom_deinit(my_mutator_t *data) { - free(data->pre_save_buf); + free(data->post_process_buf); free(data->havoc_buf); free(data->data_buf); free(data->fuzz_buf); diff --git a/examples/custom_mutators/example.py b/examples/custom_mutators/example.py index 3c3fa8c1..cf659e5a 100644 --- a/examples/custom_mutators/example.py +++ b/examples/custom_mutators/example.py @@ -120,7 +120,7 @@ def fuzz(buf, add_buf, max_size): # # return next_index # -# def pre_save(buf): +# def post_process(buf): # ''' # Called just before the execution to write the test case in the format # expected by the target diff --git a/examples/post_library/post_library.so.c b/examples/post_library/post_library.so.c index 0aa780cb..d9504b23 100644 --- a/examples/post_library/post_library.so.c +++ b/examples/post_library/post_library.so.c @@ -83,7 +83,7 @@ typedef struct post_state { } post_state_t; -void *afl_postprocess_init(void *afl) { +void *afl_postprocess_init(void *afl, unsigned int seed) { post_state_t *state = malloc(sizeof(post_state_t)); if (!state) { diff --git a/examples/post_library/post_library_png.so.c b/examples/post_library/post_library_png.so.c index 41ba4f5e..b29afd62 100644 --- a/examples/post_library/post_library_png.so.c +++ b/examples/post_library/post_library_png.so.c @@ -43,7 +43,7 @@ typedef struct post_state { } post_state_t; -void *afl_postprocess_init(void *afl) { +void *afl_postprocess_init(void *afl, unsigned int seed) { post_state_t *state = malloc(sizeof(post_state_t)); if (!state) { |