aboutsummaryrefslogtreecommitdiff
path: root/examples/custom_mutators
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2020-03-30 16:38:51 +0200
committerDominik Maier <domenukk@gmail.com>2020-03-30 16:46:54 +0200
commit1f257c5875d8b99d774ec9f473c06f73862d0688 (patch)
tree6d647a3c3caae30ebd90a2a2da80af3481f0f5bd /examples/custom_mutators
parente2a3de71ca8c9ab36d43fac2752e4a9ccf31e814 (diff)
downloadafl++-1f257c5875d8b99d774ec9f473c06f73862d0688.tar.gz
fixed example
Diffstat (limited to 'examples/custom_mutators')
-rw-r--r--examples/custom_mutators/example.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/examples/custom_mutators/example.c b/examples/custom_mutators/example.c
index ec47104d..c8200b26 100644
--- a/examples/custom_mutators/example.c
+++ b/examples/custom_mutators/example.c
@@ -142,34 +142,25 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size,
size_t afl_custom_pre_save(my_mutator_t *data, uint8_t *buf, size_t buf_size,
uint8_t **out_buf) {
- if (data->pre_save_size < buf_size + 5) {
+ uint8_t *pre_save_buf = maybe_grow(BUF_PARAMS(data, pre_save), buf_size + 5);
+ if (!pre_save_buf) {
- data->pre_save_buf = maybe_grow(BUF_PARAMS(data, pre_save), buf_size + 5);
- if (!data->pre_save_buf) {
-
- perror("custom mutator realloc failed.");
- *out_buf = NULL;
- return 0;
-
- }
-
- data->pre_save_size = buf_size + 5;
+ perror("custom mutator realloc failed.");
+ *out_buf = NULL;
+ return 0;
}
- uint8_t *pre_save_buf = data->pre_save_buf;
-
- memcpy(pre_save_buf, buf, buf_size);
- size_t out_buf_size = buf_size + 5;
- pre_save_buf[buf_size + 0] = 'A';
- pre_save_buf[buf_size + 1] = 'F';
- pre_save_buf[buf_size + 2] = 'L';
- pre_save_buf[buf_size + 3] = '+';
- pre_save_buf[buf_size + 4] = '+';
+ 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] = '+';
*out_buf = pre_save_buf;
- return out_buf_size;
+ return buf_size + 5;
}