aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-07-09 10:32:14 +0200
committervanhauser-thc <vh@thc.org>2021-07-09 10:32:14 +0200
commite1d5009229fb5cea5845cd08e0abdc8fe440ee86 (patch)
tree5855fd6e27d83b5d7eb2c455a8bb3bc7b43403a4 /src
parentfd4acc935efe78a340395ca386b856930f7e6b22 (diff)
downloadafl++-e1d5009229fb5cea5845cd08e0abdc8fe440ee86.tar.gz
fixes
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-python.c20
-rw-r--r--src/afl-fuzz-queue.c22
2 files changed, 38 insertions, 4 deletions
diff --git a/src/afl-fuzz-python.c b/src/afl-fuzz-python.c
index 3aa97635..bb4eabcc 100644
--- a/src/afl-fuzz-python.c
+++ b/src/afl-fuzz-python.c
@@ -813,8 +813,8 @@ u8 queue_get_py(void *py_mutator, const u8 *filename) {
}
-void queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
- const u8 *filename_orig_queue) {
+u8 queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
+ const u8 *filename_orig_queue) {
PyObject *py_args, *py_value;
@@ -861,7 +861,21 @@ void queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
py_args);
Py_DECREF(py_args);
- if (py_value == NULL) {
+ if (py_value != NULL) {
+
+ int ret = PyObject_IsTrue(py_value);
+ Py_DECREF(py_value);
+
+ if (ret == -1) {
+
+ PyErr_Print();
+ FATAL("Failed to convert return value");
+
+ }
+
+ return (u8)ret & 0xFF;
+
+ } else {
PyErr_Print();
FATAL("Call failed");
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index d2689c94..48794e95 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -474,6 +474,8 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) {
if (afl->custom_mutators_count) {
+ u8 updated = 0;
+
LIST_FOREACH(&afl->custom_mutator_list, struct custom_mutator, {
if (el->afl_custom_queue_new_entry) {
@@ -487,12 +489,30 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) {
}
- el->afl_custom_queue_new_entry(el->data, fname, fname_orig);
+ if (el->afl_custom_queue_new_entry(el->data, fname, fname_orig)) {
+
+ updated = 1;
+
+ }
}
});
+ if (updated) {
+
+ struct stat st;
+ if (stat(fname, &st)) { PFATAL("File %s is gone!", fname); }
+ if (!st.st_size) {
+
+ FATAL("File %s became empty in custom mutator!", fname);
+
+ }
+
+ q->len = st.st_size;
+
+ }
+
}
/* only redqueen currently uses is_ascii */