honor afl_quiet on env var checks + code-format

This commit is contained in:
van Hauser
2020-03-11 11:42:57 +01:00
parent d8d89507b5
commit 684f4dd1c4
23 changed files with 88 additions and 86 deletions

View File

@ -77,10 +77,10 @@
/* The actual postprocessor routine called by afl-fuzz: */
const unsigned char *afl_postprocess(const unsigned char *in_buf,
unsigned int *len) {
unsigned int * len) {
static unsigned char *saved_buf;
unsigned char *new_buf;
unsigned char * new_buf;
/* Skip execution altogether for buffers shorter than 6 bytes (just to
show how it's done). We can trust *len to be sane. */

View File

@ -37,7 +37,7 @@
#include <stdlib.h>
#include <string.h>
static u8 *obj_path; /* Path to runtime libraries */
static u8 * obj_path; /* Path to runtime libraries */
static u8 **cc_params; /* Parameters passed to the real CC */
static u32 cc_par_cnt = 1; /* Param count, including argv0 */
u8 use_stdin = 0; /* dummy */

View File

@ -86,7 +86,7 @@ static void __afl_map_shm(void) {
if (id_str) {
#ifdef USEMMAP
const char *shm_file_path = id_str;
const char * shm_file_path = id_str;
int shm_fd = -1;
unsigned char *shm_base = NULL;

View File

@ -284,13 +284,13 @@ enum {
typedef struct MOpt_globals {
u64 *finds;
u64 *finds_v2;
u64 *cycles;
u64 *cycles_v2;
u64 *cycles_v3;
u64 * finds;
u64 * finds_v2;
u64 * cycles;
u64 * cycles_v2;
u64 * cycles_v3;
u32 is_pilot_mode;
u64 *pTime;
u64 * pTime;
u64 period;
char *havoc_stagename;
char *splice_stageformat;
@ -548,7 +548,7 @@ extern list_t afl_states;
struct custom_mutator {
const char *name;
void *dh;
void * dh;
/* hooks for the custom mutator function */
@ -696,8 +696,8 @@ struct custom_mutator {
* argument can be NULL while initializing the fuzzer
*/
void (*afl_custom_queue_new_entry)(afl_state_t *afl,
const u8 *filename_new_queue,
const u8 *filename_orig_queue);
const u8 * filename_new_queue,
const u8 * filename_orig_queue);
};

View File

@ -43,7 +43,7 @@ typedef struct list_element {
struct list_element *prev;
struct list_element *next;
void *data;
void * data;
} element_t;
@ -100,7 +100,7 @@ static void list_append(list_t *list, void *el) {
#define LIST_FOREACH(list, type, block) \
do { \
\
list_t *li = (list); \
list_t * li = (list); \
element_t *head = get_head((li)); \
element_t *el_box = (head)->next; \
if (!el_box) FATAL("foreach over uninitialized list"); \

View File

@ -163,7 +163,7 @@ static u32 alloc_canary;
static void *__dislocator_alloc(size_t len) {
u8 *ret;
u8 * ret;
size_t tlen;
int flags, fd, sp;
@ -338,7 +338,7 @@ void free(void *ptr) {
if (align_allocations && (len & (ALLOC_ALIGN_SIZE - 1))) {
u8 *ptr_ = ptr;
u8 * ptr_ = ptr;
size_t rlen = (len & ~(ALLOC_ALIGN_SIZE - 1)) + ALLOC_ALIGN_SIZE;
for (; len < rlen; ++len)
if (ptr_[len] != TAIL_ALLOC_CANARY)
@ -451,7 +451,7 @@ void *reallocarray(void *ptr, size_t elem_len, size_t elem_cnt) {
const size_t elem_lim = 1UL << (sizeof(size_t) * 4);
const size_t elem_tot = elem_len * elem_cnt;
void *ret = NULL;
void * ret = NULL;
if ((elem_len >= elem_lim || elem_cnt >= elem_lim) && elem_len > 0 &&
elem_cnt > (SIZE_MAX / elem_len)) {

View File

@ -160,7 +160,7 @@ static void __tokencap_load_mappings(void) {
int mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, __tokencap_pid,
sizeof(struct kinfo_vmentry)};
#endif
char *buf, *low, *high;
char * buf, *low, *high;
size_t miblen = sizeof(mib) / sizeof(mib[0]);
size_t len;

View File

@ -37,13 +37,13 @@
#include <limits.h>
#include <assert.h>
static u8 *obj_path; /* Path to runtime libraries */
static u8 * obj_path; /* Path to runtime libraries */
static u8 **cc_params; /* Parameters passed to the real CC */
static u32 cc_par_cnt = 1; /* Param count, including argv0 */
static u8 llvm_fullpath[PATH_MAX];
static u8 lto_mode;
static u8 *lto_flag = AFL_CLANG_FLTO;
static u8 *march_opt = CFLAGS_OPT;
static u8 * lto_flag = AFL_CLANG_FLTO;
static u8 * march_opt = CFLAGS_OPT;
static u8 debug;
static u8 cwd[4096];
static u8 cmplog_mode;

View File

@ -78,7 +78,7 @@ static u32 ld_param_cnt = 1, /* Number of params to 'ld' */
/* This function wipes a directory - our AR unpack directory in this case */
static u8 wipe_directory(u8 *path) {
DIR *d;
DIR * d;
struct dirent *d_ent;
d = opendir(path);
@ -330,10 +330,10 @@ static void edit_params(int argc, char **argv) {
u8 this_wd[4096], *this_ar;
u8 ar_params_cnt = 4;
u8 *ar_params[ar_params_cnt];
u8 *file = argv[i];
u8 * ar_params[ar_params_cnt];
u8 * file = argv[i];
s32 pid, status;
DIR *arx;
DIR * arx;
struct dirent *dir_ent;
if (libdir_index < libdir_cnt) file = libdir_file;

View File

@ -89,7 +89,7 @@ static void __afl_map_shm(void) {
if (id_str) {
#ifdef USEMMAP
const char *shm_file_path = id_str;
const char * shm_file_path = id_str;
int shm_fd = -1;
unsigned char *shm_base = NULL;
@ -137,7 +137,7 @@ static void __afl_map_shm(void) {
if (id_str) {
#ifdef USEMMAP
const char *shm_file_path = id_str;
const char * shm_file_path = id_str;
int shm_fd = -1;
unsigned char *shm_base = NULL;

View File

@ -130,7 +130,7 @@ static void __compcov_load(void) {
char *bin_name = getenv("AFL_COMPCOV_BINNAME");
procmaps_iterator *maps = pmparser_parse(-1);
procmaps_struct *maps_tmp = NULL;
procmaps_struct * maps_tmp = NULL;
while ((maps_tmp = pmparser_next(maps)) != NULL) {

View File

@ -32,8 +32,8 @@ implied warranty.
*/
typedef struct procmaps_struct {
void *addr_start; //< start address of the area
void *addr_end; //< end address
void * addr_start; //< start address of the area
void * addr_end; //< end address
unsigned long length; //< size of the range
char perm[5]; //< permissions rwxp

View File

@ -824,7 +824,7 @@ static void usage(u8 *argv0) {
static void find_binary(u8 *fname) {
u8 *env_path = 0;
u8 * env_path = 0;
struct stat st;
if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {

View File

@ -44,7 +44,7 @@ void detect_file_args(char **argv, u8 *prog_in, u8 *use_stdin) {
#ifdef __GLIBC__
u8 *cwd = getcwd(NULL, 0); /* non portable glibc extension */
#else
u8 *cwd;
u8 * cwd;
char *buf;
long size = pathconf(".", _PC_PATH_MAX);
if ((buf = (char *)malloc((size_t)size)) != NULL) {
@ -151,7 +151,7 @@ void argv_cpy_free(char **argv) {
char **get_qemu_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {
char **new_argv = ck_alloc(sizeof(char *) * (argc + 4));
u8 *tmp, *cp = NULL, *rsl, *own_copy;
u8 * tmp, *cp = NULL, *rsl, *own_copy;
memcpy(new_argv + 3, argv + 1, (int)(sizeof(char *)) * argc);
@ -229,7 +229,7 @@ char **get_qemu_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {
char **get_wine_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {
char **new_argv = ck_alloc(sizeof(char *) * (argc + 3));
u8 *tmp, *cp = NULL, *rsl, *own_copy;
u8 * tmp, *cp = NULL, *rsl, *own_copy;
memcpy(new_argv + 2, argv + 1, (int)(sizeof(char *)) * argc);
@ -324,6 +324,8 @@ char **get_wine_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {
void check_environment_vars(char **envp) {
if (be_quiet) return;
int index = 0, found = 0;
char *env;
while ((env = envp[index++]) != NULL) {

View File

@ -461,7 +461,7 @@ u8 *describe_op(afl_state_t *afl, u8 hnb) {
static void write_crash_readme(afl_state_t *afl) {
u8 *fn = alloc_printf("%s/crashes/README.txt", afl->out_dir);
u8 * fn = alloc_printf("%s/crashes/README.txt", afl->out_dir);
s32 fd;
FILE *f;

View File

@ -52,7 +52,7 @@ void load_extras_file(afl_state_t *afl, u8 *fname, u32 *min_len, u32 *max_len,
FILE *f;
u8 buf[MAX_LINE];
u8 *lptr;
u8 * lptr;
u32 cur_line = 0;
f = fopen(fname, "r");
@ -188,10 +188,10 @@ void load_extras_file(afl_state_t *afl, u8 *fname, u32 *min_len, u32 *max_len,
void load_extras(afl_state_t *afl, u8 *dir) {
DIR *d;
DIR * d;
struct dirent *de;
u32 min_len = MAX_DICT_FILE, max_len = 0, dict_level = 0;
u8 *x;
u8 * x;
/* If the name ends with @, extract level and continue. */
@ -224,7 +224,7 @@ void load_extras(afl_state_t *afl, u8 *dir) {
while ((de = readdir(d))) {
struct stat st;
u8 *fn = alloc_printf("%s/%s", dir, de->d_name);
u8 * fn = alloc_printf("%s/%s", dir, de->d_name);
s32 fd;
if (lstat(fn, &st) || access(fn, R_OK)) PFATAL("Unable to access '%s'", fn);

View File

@ -35,7 +35,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
cpu_set_t c;
#elif defined(__NetBSD__)
cpuset_t *c;
cpuset_t * c;
#endif
u8 cpu_used[4096] = {0};
@ -51,7 +51,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
}
#if defined(__linux__)
DIR *d;
DIR * d;
struct dirent *de;
d = opendir("/proc");
@ -76,7 +76,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
while ((de = readdir(d))) {
u8 *fn;
u8 * fn;
FILE *f;
u8 tmp[MAX_LINE];
u8 has_vmsize = 0;
@ -275,7 +275,7 @@ cpuset_destroy(c);
void setup_post(afl_state_t *afl) {
void *dh;
u8 *fn = get_afl_env("AFL_POST_LIBRARY");
u8 * fn = get_afl_env("AFL_POST_LIBRARY");
u32 tlen = 6;
if (!fn) return;
@ -321,7 +321,7 @@ void read_testcases(afl_state_t *afl) {
struct dirent **nl;
s32 nl_cnt;
u32 i;
u8 *fn1;
u8 * fn1;
/* Auto-detect non-in-place resumption attempts. */
@ -448,7 +448,7 @@ void perform_dry_run(afl_state_t *afl) {
struct queue_entry *q = afl->queue;
u32 cal_failures = 0;
u8 *skip_crashes = get_afl_env("AFL_SKIP_CRASHES");
u8 * skip_crashes = get_afl_env("AFL_SKIP_CRASHES");
while (q) {
@ -872,7 +872,7 @@ void find_timeout(afl_state_t *afl) {
static u8 delete_files(u8 *path, u8 *prefix) {
DIR *d;
DIR * d;
struct dirent *d_ent;
d = opendir(path);
@ -997,7 +997,7 @@ dir_cleanup_failed:
static void handle_existing_out_dir(afl_state_t *afl) {
FILE *f;
u8 *fn = alloc_printf("%s/fuzzer_stats", afl->out_dir);
u8 * fn = alloc_printf("%s/fuzzer_stats", afl->out_dir);
/* See if the output directory is locked. If yes, bail out. If not,
create a lock that will persist for the lifetime of the process
@ -1851,7 +1851,7 @@ static void handle_skipreq(int sig) {
void check_binary(afl_state_t *afl, u8 *fname) {
u8 *env_path = 0;
u8 * env_path = 0;
struct stat st;
s32 fd;

View File

@ -216,7 +216,7 @@ u8 trim_case_custom(afl_state_t *afl, struct queue_entry *q, u8 *in_buf) {
u32 cksum;
u8 *retbuf = NULL;
u8 * retbuf = NULL;
size_t retlen = 0;
afl->mutator->afl_custom_trim(afl, &retbuf, &retlen);

View File

@ -1567,7 +1567,7 @@ custom_mutator_stage:
struct queue_entry *target;
u32 tid;
u8 *new_buf;
u8 * new_buf;
retry_external_pick:
/* Pick a random other queue entry for passing to external API */
@ -2164,7 +2164,7 @@ retry_splicing:
struct queue_entry *target;
u32 tid, split_at;
u8 *new_buf;
u8 * new_buf;
s32 f_diff, l_diff;
/* First of all, if we've modified in_buf for havoc, let's clean that

View File

@ -43,7 +43,7 @@ int init_py_module(afl_state_t *afl, u8 *module_name) {
afl->py_module = PyImport_Import(py_name);
Py_DECREF(py_name);
PyObject *py_module = afl->py_module;
PyObject * py_module = afl->py_module;
PyObject **py_functions = afl->py_functions;
if (afl->py_module != NULL) {

View File

@ -48,7 +48,7 @@
#include <stdlib.h>
#include <string.h>
static u8 *as_path; /* Path to the AFL 'as' wrapper */
static u8 * as_path; /* Path to the AFL 'as' wrapper */
static u8 **cc_params; /* Parameters passed to the real CC */
static u32 cc_par_cnt = 1; /* Param count, including argv0 */
static u8 be_quiet, /* Quiet mode */

View File

@ -648,7 +648,7 @@ static void usage(u8 *argv0) {
static void find_binary(afl_forkserver_t *fsrv, u8 *fname) {
u8 *env_path = 0;
u8 * env_path = 0;
struct stat st;
if (strchr(fname, '/') || !(env_path = getenv("PATH"))) {
@ -928,7 +928,7 @@ int main(int argc, char **argv_orig, char **envp) {
if (in_dir) {
DIR *dir_in, *dir_out;
DIR * dir_in, *dir_out;
struct dirent *dir_ent;
int done = 0;
u8 infile[4096], outfile[4096];