aboutsummaryrefslogtreecommitdiff
path: root/examples/custom_mutators/example.c
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-03-28 13:06:05 +0100
committerhexcoder- <heiko@hexco.de>2020-03-28 13:06:05 +0100
commit23b3e3c84d3350790b5095a4bb6e1b7c39f28eea (patch)
treeb0985cafaafc01cca73cb25ec78768f59238ddc2 /examples/custom_mutators/example.c
parent8b8600fdabb20c344063ead1b0ff2d105e0365be (diff)
parent1938a122226bdecfed8420d21eeb2b240bff1b6a (diff)
downloadafl++-23b3e3c84d3350790b5095a4bb6e1b7c39f28eea.tar.gz
Merge branch 'dev' of https://github.com/AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'examples/custom_mutators/example.c')
-rw-r--r--examples/custom_mutators/example.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/examples/custom_mutators/example.c b/examples/custom_mutators/example.c
index 9a62d1a7..a9764f5b 100644
--- a/examples/custom_mutators/example.c
+++ b/examples/custom_mutators/example.c
@@ -100,6 +100,7 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size,
u8 *mutated_out = maybe_grow(BUF_PARAMS(data, fuzz), mutated_size);
if (!mutated_out) {
+ *out_buf = NULL;
perror("custom mutator allocation (maybe_grow)");
return 0; /* afl-fuzz will very likely error out after this. */
@@ -189,16 +190,24 @@ size_t afl_custom_pre_save(my_mutator_t *data, uint8_t *buf, size_t buf_size,
* @param data pointer returned in afl_custom_init for this fuzz case
* @param buf Buffer containing the test case
* @param buf_size Size of the test case
- * @return The amount of possible iteration steps to trim the input
+ * @return The amount of possible iteration steps to trim the input.
+ * negative on error.
*/
-int afl_custom_init_trim(my_mutator_t *data, uint8_t *buf, size_t buf_size) {
+int32_t afl_custom_init_trim(my_mutator_t *data, uint8_t *buf,
+ size_t buf_size) {
// We simply trim once
data->trimmming_steps = 1;
data->cur_step = 0;
- maybe_grow(BUF_PARAMS(data, trim), buf_size);
+ if (!maybe_grow(BUF_PARAMS(data, trim), buf_size)) {
+
+ perror("init_trim grow");
+ return -1;
+
+ }
+
memcpy(data->trim_buf, buf, buf_size);
data->trim_size_current = buf_size;
@@ -245,9 +254,9 @@ size_t afl_custom_trim(my_mutator_t *data, uint8_t **out_buf) {
* @param[in] data pointer returned in afl_custom_init for this fuzz case
* @param success Indicates if the last trim operation was successful.
* @return The next trim iteration index (from 0 to the maximum amount of
- * steps returned in init_trim)
+ * steps returned in init_trim). negative ret on failure.
*/
-int afl_custom_post_trim(my_mutator_t *data, int success) {
+int32_t afl_custom_post_trim(my_mutator_t *data, int success) {
if (success) {