aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-11-18 21:25:35 +0100
committerGitHub <noreply@github.com>2020-11-18 21:25:35 +0100
commit4d9eb9bda147a26fc8cbe885b6193cf0c94c6314 (patch)
treec7a903633c7d1b0b5e373535188fd3a458a7f329 /include
parent4c59c5234aec0469e4dd02561dbd84387bd53155 (diff)
parentcd0a25be5e9b05a2ab6a11592cd95e7f653bf42d (diff)
downloadafl++-4d9eb9bda147a26fc8cbe885b6193cf0c94c6314.tar.gz
Merge pull request #607 from AFLplusplus/dev
push to stable
Diffstat (limited to 'include')
-rw-r--r--include/afl-fuzz.h41
-rw-r--r--include/alloc-inl.h22
-rw-r--r--include/envs.h3
3 files changed, 46 insertions, 20 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index e59d5f90..933af65d 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -113,6 +113,7 @@
#include <kstat.h>
#include <sys/sysinfo.h>
#include <sys/pset.h>
+ #include <strings.h>
#endif
#endif /* __linux__ */
@@ -310,6 +311,7 @@ enum {
/* 09 */ PY_FUNC_HAVOC_MUTATION_PROBABILITY,
/* 10 */ PY_FUNC_QUEUE_GET,
/* 11 */ PY_FUNC_QUEUE_NEW_ENTRY,
+ /* 12 */ PY_FUNC_INTROSPECTION,
PY_FUNC_COUNT
};
@@ -324,8 +326,7 @@ typedef struct py_mutator {
u8 * fuzz_buf;
size_t fuzz_size;
- u8 * post_process_buf;
- size_t post_process_size;
+ Py_buffer post_process_buf;
u8 * trim_buf;
size_t trim_size;
@@ -361,8 +362,8 @@ typedef struct afl_env_vars {
u8 afl_skip_cpufreq, afl_exit_when_done, afl_no_affinity, afl_skip_bin_check,
afl_dumb_forksrv, afl_import_first, afl_custom_mutator_only, afl_no_ui,
afl_force_ui, afl_i_dont_care_about_missing_crashes, afl_bench_just_one,
- afl_bench_until_crash, afl_debug_child_output, afl_autoresume,
- afl_cal_fast, afl_cycle_schedules, afl_expand_havoc, afl_statsd;
+ afl_bench_until_crash, afl_debug_child, afl_autoresume, afl_cal_fast,
+ afl_cycle_schedules, afl_expand_havoc, afl_statsd;
u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path,
*afl_hang_tmout, *afl_forksrv_init_tmout, *afl_skip_crashes, *afl_preload,
@@ -684,6 +685,8 @@ typedef struct afl_state {
u32 custom_mutators_count;
+ struct custom_mutator *current_custom_fuzz;
+
list_t custom_mutator_list;
/* this is a fixed buffer of size map_size that can be used by any function if
@@ -748,6 +751,15 @@ struct custom_mutator {
void *(*afl_custom_init)(afl_state_t *afl, unsigned int seed);
/**
+ * When afl-fuzz was compiled with INTROSPECTION=1 then custom mutators can
+ * also give introspection information back with this function.
+ *
+ * @param data pointer returned in afl_custom_init for this fuzz case
+ * @return pointer to a text string (const char*)
+ */
+ const char *(*afl_custom_introspection)(void *data);
+
+ /**
* This method is called just before fuzzing a queue entry with the custom
* mutator, and receives the initial buffer. It should return the number of
* fuzzes to perform.
@@ -953,16 +965,17 @@ u8 trim_case_custom(afl_state_t *, struct queue_entry *q, u8 *in_buf,
struct custom_mutator *load_custom_mutator_py(afl_state_t *, char *);
void finalize_py_module(void *);
-u32 fuzz_count_py(void *, const u8 *, size_t);
-size_t post_process_py(void *, u8 *, size_t, u8 **);
-s32 init_trim_py(void *, u8 *, size_t);
-s32 post_trim_py(void *, u8);
-size_t trim_py(void *, u8 **);
-size_t havoc_mutation_py(void *, u8 *, size_t, u8 **, size_t);
-u8 havoc_mutation_probability_py(void *);
-u8 queue_get_py(void *, const u8 *);
-void queue_new_entry_py(void *, const u8 *, const u8 *);
-void deinit_py(void *);
+u32 fuzz_count_py(void *, const u8 *, size_t);
+size_t post_process_py(void *, u8 *, size_t, u8 **);
+s32 init_trim_py(void *, u8 *, size_t);
+s32 post_trim_py(void *, u8);
+size_t trim_py(void *, u8 **);
+size_t havoc_mutation_py(void *, u8 *, size_t, u8 **, size_t);
+u8 havoc_mutation_probability_py(void *);
+u8 queue_get_py(void *, const u8 *);
+const char *introspection_py(void *);
+void queue_new_entry_py(void *, const u8 *, const u8 *);
+void deinit_py(void *);
#endif
diff --git a/include/alloc-inl.h b/include/alloc-inl.h
index d7aa51a7..68255fb6 100644
--- a/include/alloc-inl.h
+++ b/include/alloc-inl.h
@@ -636,7 +636,7 @@ struct afl_alloc_buf {
#define AFL_ALLOC_SIZE_OFFSET (offsetof(struct afl_alloc_buf, buf))
-/* Returs the container element to this ptr */
+/* Returns the container element to this ptr */
static inline struct afl_alloc_buf *afl_alloc_bufptr(void *buf) {
return (struct afl_alloc_buf *)((u8 *)buf - AFL_ALLOC_SIZE_OFFSET);
@@ -694,12 +694,18 @@ static inline void *afl_realloc(void **buf, size_t size_needed) {
}
/* alloc */
- new_buf = (struct afl_alloc_buf *)realloc(new_buf, next_size);
- if (unlikely(!new_buf)) {
+ struct afl_alloc_buf *newer_buf =
+ (struct afl_alloc_buf *)realloc(new_buf, next_size);
+ if (unlikely(!newer_buf)) {
+ free(new_buf); // avoid a leak
*buf = NULL;
return NULL;
+ } else {
+
+ new_buf = newer_buf;
+
}
new_buf->complete_size = next_size;
@@ -730,12 +736,18 @@ static inline void *afl_realloc_exact(void **buf, size_t size_needed) {
if (unlikely(current_size == size_needed)) { return *buf; }
/* alloc */
- new_buf = (struct afl_alloc_buf *)realloc(new_buf, size_needed);
- if (unlikely(!new_buf)) {
+ struct afl_alloc_buf *newer_buf =
+ (struct afl_alloc_buf *)realloc(new_buf, size_needed);
+ if (unlikely(!newer_buf)) {
+ free(new_buf); // avoid a leak
*buf = NULL;
return NULL;
+ } else {
+
+ new_buf = newer_buf;
+
}
new_buf->complete_size = size_needed;
diff --git a/include/envs.h b/include/envs.h
index b753d5f8..8255cf4f 100644
--- a/include/envs.h
+++ b/include/envs.h
@@ -6,6 +6,7 @@ static char *afl_environment_deprecated[] = {
"AFL_LLVM_WHITELIST",
"AFL_GCC_WHITELIST",
+ "AFL_DEBUG_CHILD_OUTPUT",
"AFL_DEFER_FORKSRV",
"AFL_POST_LIBRARY",
"AFL_PERSISTENT",
@@ -36,7 +37,7 @@ static char *afl_environment_variables[] = {
"AFL_CXX",
"AFL_CYCLE_SCHEDULES",
"AFL_DEBUG",
- "AFL_DEBUG_CHILD_OUTPUT",
+ "AFL_DEBUG_CHILD",
"AFL_DEBUG_GDB",
"AFL_DISABLE_TRIM",
"AFL_DONT_OPTIMIZE",