mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-16 03:48:08 +00:00
fix attempt at post_process implementation
This commit is contained in:
@ -219,11 +219,14 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
|
||||
|
||||
if (py_module != NULL) {
|
||||
|
||||
u8 py_notrim = 0, py_idx;
|
||||
/* init, required */
|
||||
u8 py_notrim = 0;
|
||||
py_functions[PY_FUNC_INIT] = PyObject_GetAttrString(py_module, "init");
|
||||
if (!py_functions[PY_FUNC_INIT])
|
||||
FATAL("init function not found in python module");
|
||||
if (!py_functions[PY_FUNC_INIT]) {
|
||||
|
||||
WARNF("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");
|
||||
@ -231,12 +234,6 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
|
||||
PyObject_GetAttrString(py_module, "describe");
|
||||
py_functions[PY_FUNC_FUZZ_COUNT] =
|
||||
PyObject_GetAttrString(py_module, "fuzz_count");
|
||||
if (!py_functions[PY_FUNC_FUZZ]) {
|
||||
|
||||
WARNF("fuzz function not found in python module");
|
||||
|
||||
}
|
||||
|
||||
py_functions[PY_FUNC_POST_PROCESS] =
|
||||
PyObject_GetAttrString(py_module, "post_process");
|
||||
py_functions[PY_FUNC_INIT_TRIM] =
|
||||
@ -263,36 +260,6 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
|
||||
if (!py_functions[PY_FUNC_DEINIT])
|
||||
WARNF("deinit function not found in python module");
|
||||
|
||||
for (py_idx = 0; py_idx < PY_FUNC_COUNT; ++py_idx) {
|
||||
|
||||
if (!py_functions[py_idx] || !PyCallable_Check(py_functions[py_idx])) {
|
||||
|
||||
if (py_idx >= PY_FUNC_INIT_TRIM && py_idx <= PY_FUNC_TRIM) {
|
||||
|
||||
// Implementing the trim API is optional for now
|
||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
||||
py_notrim = 1;
|
||||
|
||||
} else if (py_idx >= PY_OPTIONAL) {
|
||||
|
||||
// Only _init and _deinit are not optional currently
|
||||
|
||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
||||
|
||||
} else {
|
||||
|
||||
fprintf(stderr,
|
||||
"Cannot find/call function with index %d in external "
|
||||
"Python module.\n",
|
||||
py_idx);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (py_notrim) {
|
||||
|
||||
py_functions[PY_FUNC_INIT_TRIM] = NULL;
|
||||
@ -345,6 +312,8 @@ static void init_py(afl_state_t *afl, py_mutator_t *py_mutator,
|
||||
|
||||
(void)afl;
|
||||
|
||||
if (py_mutator->py_functions[PY_FUNC_INIT] == NULL) { return; }
|
||||
|
||||
PyObject *py_args, *py_value;
|
||||
|
||||
/* Provide the init function a seed for the Python RNG */
|
||||
|
Reference in New Issue
Block a user