aboutsummaryrefslogtreecommitdiff
path: root/src/afl-fuzz-python.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-12 11:12:25 +0200
committervan Hauser <vh@thc.org>2020-05-12 11:12:25 +0200
commit7b40d7b9420b2e3adb7d9afa88610199718dedba (patch)
treec420c91a6dcfde9a2bcffcdde22bb279cf72c243 /src/afl-fuzz-python.c
parenta578d719e1f556db07ca3c7e2fe38b7668c204d8 (diff)
downloadafl++-7b40d7b9420b2e3adb7d9afa88610199718dedba.tar.gz
new code formatting + applied
Diffstat (limited to 'src/afl-fuzz-python.c')
-rw-r--r--src/afl-fuzz-python.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/afl-fuzz-python.c b/src/afl-fuzz-python.c
index 832dba06..1084e4f1 100644
--- a/src/afl-fuzz-python.c
+++ b/src/afl-fuzz-python.c
@@ -35,11 +35,11 @@ static void *unsupported(afl_state_t *afl, unsigned int seed) {
}
-/* sorry for this makro...
-it just fills in `&py_mutator->something_buf, &py_mutator->something_size`. */
-#define BUF_PARAMS(name) \
- (void **)&((py_mutator_t *)py_mutator)->name##_buf, \
- &((py_mutator_t *)py_mutator)->name##_size
+ /* sorry for this makro...
+ it just fills in `&py_mutator->something_buf, &py_mutator->something_size`. */
+ #define BUF_PARAMS(name) \
+ (void **)&((py_mutator_t *)py_mutator)->name##_buf, \
+ &((py_mutator_t *)py_mutator)->name##_size
static size_t fuzz_py(void *py_mutator, u8 *buf, size_t buf_size, u8 **out_buf,
u8 *add_buf, size_t add_buf_size, size_t max_size) {
@@ -71,12 +71,12 @@ static size_t fuzz_py(void *py_mutator, u8 *buf, size_t buf_size, u8 **out_buf,
PyTuple_SetItem(py_args, 1, py_value);
-/* max_size */
-#if PY_MAJOR_VERSION >= 3
+ /* max_size */
+ #if PY_MAJOR_VERSION >= 3
py_value = PyLong_FromLong(max_size);
-#else
+ #else
py_value = PyInt_FromLong(max_size);
-#endif
+ #endif
if (!py_value) {
Py_DECREF(py_args);
@@ -118,11 +118,11 @@ static py_mutator_t *init_py_module(afl_state_t *afl, u8 *module_name) {
Py_Initialize();
-#if PY_MAJOR_VERSION >= 3
+ #if PY_MAJOR_VERSION >= 3
PyObject *py_name = PyUnicode_FromString(module_name);
-#else
+ #else
PyObject *py_name = PyString_FromString(module_name);
-#endif
+ #endif
py->py_module = PyImport_Import(py_name);
Py_DECREF(py_name);
@@ -243,11 +243,11 @@ static void init_py(afl_state_t *afl, py_mutator_t *py_mutator,
/* Provide the init function a seed for the Python RNG */
py_args = PyTuple_New(1);
-#if PY_MAJOR_VERSION >= 3
+ #if PY_MAJOR_VERSION >= 3
py_value = PyLong_FromLong(seed);
-#else
+ #else
py_value = PyInt_FromLong(seed);
-#endif
+ #endif
if (!py_value) {
@@ -440,11 +440,11 @@ s32 init_trim_py(void *py_mutator, u8 *buf, size_t buf_size) {
if (py_value != NULL) {
-#if PY_MAJOR_VERSION >= 3
+ #if PY_MAJOR_VERSION >= 3
u32 retcnt = (u32)PyLong_AsLong(py_value);
-#else
+ #else
u32 retcnt = PyInt_AsLong(py_value);
-#endif
+ #endif
Py_DECREF(py_value);
return retcnt;
@@ -479,11 +479,11 @@ s32 post_trim_py(void *py_mutator, u8 success) {
if (py_value != NULL) {
-#if PY_MAJOR_VERSION >= 3
+ #if PY_MAJOR_VERSION >= 3
u32 retcnt = (u32)PyLong_AsLong(py_value);
-#else
+ #else
u32 retcnt = PyInt_AsLong(py_value);
-#endif
+ #endif
Py_DECREF(py_value);
return retcnt;
@@ -542,12 +542,12 @@ size_t havoc_mutation_py(void *py_mutator, u8 *buf, size_t buf_size,
PyTuple_SetItem(py_args, 0, py_value);
-/* max_size */
-#if PY_MAJOR_VERSION >= 3
+ /* max_size */
+ #if PY_MAJOR_VERSION >= 3
py_value = PyLong_FromLong(max_size);
-#else
+ #else
py_value = PyInt_FromLong(max_size);
-#endif
+ #endif
if (!py_value) {
Py_DECREF(py_args);
@@ -624,12 +624,12 @@ u8 queue_get_py(void *py_mutator, const u8 *filename) {
py_args = PyTuple_New(1);
-// File name
-#if PY_MAJOR_VERSION >= 3
+ // File name
+ #if PY_MAJOR_VERSION >= 3
py_value = PyUnicode_FromString(filename);
-#else
+ #else
py_value = PyString_FromString(filename);
-#endif
+ #endif
if (!py_value) {
Py_DECREF(py_args);
@@ -674,12 +674,12 @@ void queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
py_args = PyTuple_New(2);
-// New queue
-#if PY_MAJOR_VERSION >= 3
+ // New queue
+ #if PY_MAJOR_VERSION >= 3
py_value = PyUnicode_FromString(filename_new_queue);
-#else
+ #else
py_value = PyString_FromString(filename_new_queue);
-#endif
+ #endif
if (!py_value) {
Py_DECREF(py_args);
@@ -693,11 +693,11 @@ void queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
py_value = Py_None;
if (filename_orig_queue) {
-#if PY_MAJOR_VERSION >= 3
+ #if PY_MAJOR_VERSION >= 3
py_value = PyUnicode_FromString(filename_orig_queue);
-#else
+ #else
py_value = PyString_FromString(filename_orig_queue);
-#endif
+ #endif
if (!py_value) {
Py_DECREF(py_args);
@@ -724,7 +724,7 @@ void queue_new_entry_py(void *py_mutator, const u8 *filename_new_queue,
}
-#undef BUF_PARAMS
+ #undef BUF_PARAMS
#endif /* USE_PYTHON */