mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 12:18:08 +00:00
make py functions as optional as they are in the doc
This commit is contained in:
@ -288,17 +288,19 @@ enum {
|
|||||||
enum {
|
enum {
|
||||||
|
|
||||||
/* 00 */ PY_FUNC_INIT,
|
/* 00 */ PY_FUNC_INIT,
|
||||||
/* 01 */ PY_FUNC_FUZZ,
|
/* 01 */ PY_FUNC_DEINIT,
|
||||||
/* 02 */ PY_FUNC_POST_PROCESS,
|
/* FROM HERE ON BELOW ALL ARE OPTIONAL */
|
||||||
/* 03 */ PY_FUNC_INIT_TRIM,
|
/* 02 */ PY_OPTIONAL = 2,
|
||||||
/* 04 */ PY_FUNC_POST_TRIM,
|
/* 02 */ PY_FUNC_FUZZ = 2,
|
||||||
/* 05 */ PY_FUNC_TRIM,
|
/* 03 */ PY_FUNC_FUZZ_COUNT,
|
||||||
/* 06 */ PY_FUNC_HAVOC_MUTATION,
|
/* 04 */ PY_FUNC_POST_PROCESS,
|
||||||
/* 07 */ PY_FUNC_HAVOC_MUTATION_PROBABILITY,
|
/* 05 */ PY_FUNC_INIT_TRIM,
|
||||||
/* 08 */ PY_FUNC_QUEUE_GET,
|
/* 06 */ PY_FUNC_POST_TRIM,
|
||||||
/* 09 */ PY_FUNC_QUEUE_NEW_ENTRY,
|
/* 07 */ PY_FUNC_TRIM,
|
||||||
/* 10 */ PY_FUNC_DEINIT,
|
/* 08 */ PY_FUNC_HAVOC_MUTATION,
|
||||||
/* 11 */ PY_FUNC_FUZZ_COUNT,
|
/* 09 */ PY_FUNC_HAVOC_MUTATION_PROBABILITY,
|
||||||
|
/* 10 */ PY_FUNC_QUEUE_GET,
|
||||||
|
/* 11 */ PY_FUNC_QUEUE_NEW_ENTRY,
|
||||||
PY_FUNC_COUNT
|
PY_FUNC_COUNT
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -144,7 +144,8 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
|
|||||||
py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "fuzz");
|
py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "fuzz");
|
||||||
if (!py_functions[PY_FUNC_FUZZ])
|
if (!py_functions[PY_FUNC_FUZZ])
|
||||||
py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "mutate");
|
py_functions[PY_FUNC_FUZZ] = PyObject_GetAttrString(py_module, "mutate");
|
||||||
py_functions[PY_FUNC_FUZZ_COUNT] = PyObject_GetAttrString(py_module, "fuzz_count");
|
py_functions[PY_FUNC_FUZZ_COUNT] =
|
||||||
|
PyObject_GetAttrString(py_module, "fuzz_count");
|
||||||
if (!py_functions[PY_FUNC_FUZZ])
|
if (!py_functions[PY_FUNC_FUZZ])
|
||||||
WARNF("fuzz function not found in python module");
|
WARNF("fuzz function not found in python module");
|
||||||
py_functions[PY_FUNC_POST_PROCESS] =
|
py_functions[PY_FUNC_POST_PROCESS] =
|
||||||
@ -170,27 +171,20 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
|
|||||||
|
|
||||||
if (!py_functions[py_idx] || !PyCallable_Check(py_functions[py_idx])) {
|
if (!py_functions[py_idx] || !PyCallable_Check(py_functions[py_idx])) {
|
||||||
|
|
||||||
if (py_idx == PY_FUNC_POST_PROCESS) {
|
if (py_idx >= PY_FUNC_INIT_TRIM && py_idx <= PY_FUNC_TRIM) {
|
||||||
|
|
||||||
// Implenting the post_process API is optional for now
|
|
||||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
|
||||||
|
|
||||||
} else if (py_idx >= PY_FUNC_INIT_TRIM && py_idx <= PY_FUNC_TRIM) {
|
|
||||||
|
|
||||||
// Implementing the trim API is optional for now
|
// Implementing the trim API is optional for now
|
||||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
if (PyErr_Occurred()) { PyErr_Print(); }
|
||||||
py_notrim = 1;
|
py_notrim = 1;
|
||||||
|
|
||||||
} else if ((py_idx >= PY_FUNC_HAVOC_MUTATION) &&
|
} else if (py_idx >= PY_OPTIONAL) {
|
||||||
|
|
||||||
(py_idx <= PY_FUNC_QUEUE_NEW_ENTRY)) {
|
// Only _init and _deinit are not optional currently
|
||||||
|
|
||||||
// Implenting the havoc and queue API is optional for now
|
|
||||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
|
||||||
|
|
||||||
} else if (py_idx != PY_FUNC_FUZZ_COUNT) {
|
|
||||||
|
|
||||||
if (PyErr_Occurred()) { PyErr_Print(); }
|
if (PyErr_Occurred()) { PyErr_Print(); }
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Cannot find/call function with index %d in external "
|
"Cannot find/call function with index %d in external "
|
||||||
"Python module.\n",
|
"Python module.\n",
|
||||||
|
Reference in New Issue
Block a user