about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-12 17:05:12 +0200
committervan Hauser <vh@thc.org>2020-05-12 17:05:12 +0200
commit060f4ea320b2417bab2f153779b248698544f536 (patch)
treece326b3bae0f992008ebf8833bbdcbedee67ac5c /src
parent61779547733699dfe6710a74529e02d515364aa4 (diff)
downloadafl++-060f4ea320b2417bab2f153779b248698544f536.tar.gz
enforce mandatary custom functions
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-mutators.c6
-rw-r--r--src/afl-fuzz-python.c8
2 files changed, 11 insertions, 3 deletions
diff --git a/src/afl-fuzz-mutators.c b/src/afl-fuzz-mutators.c
index 6bd13e2b..2c2efc94 100644
--- a/src/afl-fuzz-mutators.c
+++ b/src/afl-fuzz-mutators.c
@@ -151,7 +151,7 @@ struct custom_mutator *load_custom_mutator(afl_state_t *afl, const char *fn) {
   /* Mutator */
   /* "afl_custom_init", optional for backward compatibility */
   mutator->afl_custom_init = dlsym(dh, "afl_custom_init");
-  if (!mutator->afl_custom_init) WARNF("Symbol 'afl_custom_init' not found.");
+  if (!mutator->afl_custom_init) FATAL("Symbol 'afl_custom_init' not found.");
 
   /* "afl_custom_fuzz" or "afl_custom_mutator", required */
   mutator->afl_custom_fuzz = dlsym(dh, "afl_custom_fuzz");
@@ -162,13 +162,13 @@ struct custom_mutator *load_custom_mutator(afl_state_t *afl, const char *fn) {
 
     mutator->afl_custom_fuzz = dlsym(dh, "afl_custom_mutator");
     if (!mutator->afl_custom_fuzz)
-      FATAL("Symbol 'afl_custom_mutator' not found.");
+      WARNF("Symbol 'afl_custom_mutator' not found.");
 
   }
 
   /* "afl_custom_deinit", optional for backward compatibility */
   mutator->afl_custom_deinit = dlsym(dh, "afl_custom_deinit");
-  if (!mutator->afl_custom_deinit) WARNF("Symbol 'afl_custom_init' not found.");
+  if (!mutator->afl_custom_deinit) FATAL("Symbol 'afl_custom_init' not found.");
 
   /* "afl_custom_pre_save", optional */
   mutator->afl_custom_pre_save = dlsym(dh, "afl_custom_pre_save");
diff --git a/src/afl-fuzz-python.c b/src/afl-fuzz-python.c
index 1084e4f1..460d6683 100644
--- a/src/afl-fuzz-python.c
+++ b/src/afl-fuzz-python.c
@@ -135,7 +135,13 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
     u8 py_notrim = 0, py_idx;
     /* init, required */
     py_functions[PY_FUNC_INIT] = PyObject_GetAttrString(py_module, "init");
+    if (!py_functions[PY_FUNC_INIT])
+      FATAL("init function not found in python module");
     py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "fuzz");
+    if (!py_functions[PY_FUNC_FUZZ])
+      py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "mutate");
+    if (!py_functions[PY_FUNC_FUZZ])
+      WARNF("fuzz function not found in python module");
     py_functions[PY_FUNC_PRE_SAVE] =
         PyObject_GetAttrString(py_module, "pre_save");
     py_functions[PY_FUNC_INIT_TRIM] =
@@ -152,6 +158,8 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
     py_functions[PY_FUNC_QUEUE_NEW_ENTRY] =
         PyObject_GetAttrString(py_module, "queue_new_entry");
     py_functions[PY_FUNC_DEINIT] = PyObject_GetAttrString(py_module, "deinit");
+    if (!py_functions[PY_FUNC_DEINIT])
+      FATAL("deinit function not found in python module");
 
     for (py_idx = 0; py_idx < PY_FUNC_COUNT; ++py_idx) {