code format

This commit is contained in:
van Hauser
2021-01-04 23:13:56 +01:00
parent d367b033a2
commit 6c095b3937
15 changed files with 63 additions and 46 deletions

View File

@ -691,17 +691,26 @@ static void __afl_start_forkserver(void) {
void (*old_sigchld_handler)(int) = 0; // = signal(SIGCHLD, SIG_DFL);
if (__afl_map_size <= FS_OPT_MAX_MAPSIZE)
if (__afl_map_size <= FS_OPT_MAX_MAPSIZE) {
status_for_fsrv |= (FS_OPT_SET_MAPSIZE(__afl_map_size) | FS_OPT_MAPSIZE);
if (__afl_dictionary_len && __afl_dictionary) status_for_fsrv |= FS_OPT_AUTODICT;
if (__afl_sharedmem_fuzzing != 0) status_for_fsrv |= FS_OPT_SHDMEM_FUZZ;
if (status_for_fsrv) status_for_fsrv |= (FS_OPT_ENABLED);
}
if (__afl_dictionary_len && __afl_dictionary) {
status_for_fsrv |= FS_OPT_AUTODICT;
}
if (__afl_sharedmem_fuzzing != 0) { status_for_fsrv |= FS_OPT_SHDMEM_FUZZ; }
if (status_for_fsrv) { status_for_fsrv |= (FS_OPT_ENABLED); }
memcpy(tmp, &status_for_fsrv, 4);
/* Phone home and tell the parent that we're OK. If parent isn't there,
assume we're not running in forkserver mode and just execute program. */
if (write(FORKSRV_FD + 1, tmp, 4) != 4) return;
if (write(FORKSRV_FD + 1, tmp, 4) != 4) { return; }
if (__afl_sharedmem_fuzzing || (__afl_dictionary_len && __afl_dictionary)) {

View File

@ -100,9 +100,9 @@ class AFLLTOPass : public ModulePass {
bool AFLLTOPass::runOnModule(Module &M) {
LLVMContext & C = M.getContext();
std::vector<std::string> dictionary;
// std::vector<CallInst *> calls;
LLVMContext & C = M.getContext();
std::vector<std::string> dictionary;
// std::vector<CallInst *> calls;
DenseMap<Value *, std::string *> valueMap;
std::vector<BasicBlock *> BlockList;
char * ptr;

View File

@ -234,9 +234,9 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
auto ty0 = op0->getType();
if (ty0->isHalfTy()
#if LLVM_VERSION_MAJOR >= 11
|| ty0->isBFloatTy()
|| ty0->isBFloatTy()
#endif
)
)
max_size = 16;
else if (ty0->isFloatTy())
max_size = 32;
@ -253,15 +253,15 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
if (intTyOp0 && intTyOp1) {
max_size = intTyOp0->getBitWidth() > intTyOp1->getBitWidth()
? intTyOp0->getBitWidth()
: intTyOp1->getBitWidth();
? intTyOp0->getBitWidth()
: intTyOp1->getBitWidth();
args.push_back(V0);
args.push_back(V1);
} else {
max_size = 0;
}
}

View File

@ -68,7 +68,7 @@ class CompareTransform : public ModulePass {
const char *getPassName() const override {
#else
StringRef getPassName() const override {
StringRef getPassName() const override {
#endif
return "transforms compare functions";
@ -106,23 +106,26 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
FunctionCallee tolowerFn;
#endif
{
#if LLVM_VERSION_MAJOR < 9
Constant *
Constant *
#else
FunctionCallee
FunctionCallee
#endif
c = M.getOrInsertFunction("tolower", Int32Ty, Int32Ty
c = M.getOrInsertFunction("tolower", Int32Ty, Int32Ty
#if LLVM_VERSION_MAJOR < 5
,
NULL
,
NULL
#endif
);
);
#if LLVM_VERSION_MAJOR < 9
tolowerFn = cast<Function>(c);
tolowerFn = cast<Function>(c);
#else
tolowerFn = c;
tolowerFn = c;
#endif
}
/* iterate over all functions, bbs and instruction and add suitable calls to
* strcmp/memcmp/strncmp/strcasecmp/strncasecmp */
for (auto &F : M) {

View File

@ -121,9 +121,12 @@ char compiler_mode_string[7][12] = {
u8 *getthecwd() {
if (getcwd(cwd, sizeof(cwd)) == NULL) {
static u8 fail[] = "";
return fail;
}
return cwd;
}
@ -1451,11 +1454,11 @@ int main(int argc, char **argv, char **envp) {
"of afl-cc.\n\n");
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
#define NATIVE_MSG \
" NATIVE: use llvm's native PCGUARD instrumentation (less " \
"performant)\n"
#define NATIVE_MSG \
" NATIVE: use llvm's native PCGUARD instrumentation (less " \
"performant)\n"
#else
#define NATIVE_MSG ""
#define NATIVE_MSG ""
#endif
SAYF(
@ -1463,7 +1466,7 @@ int main(int argc, char **argv, char **envp) {
"available)\n"
" PCGUARD: Dominator tree instrumentation (best!) (README.llvm.md)\n"
NATIVE_MSG
NATIVE_MSG
" CLASSIC: decision target instrumentation (README.llvm.md)\n"
" CTX: CLASSIC + callee context (instrumentation/README.ctx.md)\n"
@ -1635,7 +1638,7 @@ int main(int argc, char **argv, char **envp) {
if (!instrument_mode) {
instrument_mode = INSTRUMENT_CFG;
//ptr = instrument_mode_string[instrument_mode];
// ptr = instrument_mode_string[instrument_mode];
}

View File

@ -703,7 +703,7 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
if (!classified) {
classify_counts(&afl->fsrv);
// classified = 1;
// classified = 1;
}

View File

@ -450,7 +450,7 @@ void add_extra(afl_state_t *afl, u8 *mem, u32 len) {
if (len > MAX_DICT_FILE) {
u8 val_bufs[2][STRINGIFY_VAL_SIZE_MAX];
u8 val_bufs[2][STRINGIFY_VAL_SIZE_MAX];
WARNF("Extra '%.*s' is too big (%s, limit is %s), skipping file!", (int)len,
mem, stringify_mem_size(val_bufs[0], sizeof(val_bufs[0]), len),
stringify_mem_size(val_bufs[1], sizeof(val_bufs[1]), MAX_DICT_FILE));

View File

@ -324,7 +324,7 @@ u8 trim_case_custom(afl_state_t *afl, struct queue_entry *q, u8 *in_buf,
} else {
afl->stage_max = retval;
}
if (afl->not_on_tty && afl->debug) {

View File

@ -489,7 +489,7 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) {
void destroy_queue(afl_state_t *afl) {
u32 i;
u32 i;
for (i = 0; i < afl->queued_paths; i++) {

View File

@ -446,7 +446,8 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) {
u32 k;
u8 cons_ff = 0, cons_0 = 0;
if (shape > sizeof(v)) FATAL("shape is greater than %zu, please report!", sizeof(v));
if (shape > sizeof(v))
FATAL("shape is greater than %zu, please report!", sizeof(v));
for (k = 0; k < shape; ++k) {
@ -670,8 +671,8 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) {
u8 status = 0;
// opt not in the paper
// u32 fails = 0;
u8 found_one = 0;
// u32 fails = 0;
u8 found_one = 0;
for (i = 0; i < loggeds; ++i) {

View File

@ -682,7 +682,7 @@ void sync_fuzzers(afl_state_t *afl) {
// same time. If so, the first temporary main node running again will demote
// themselves so this is not an issue
// u8 path2[PATH_MAX];
// u8 path2[PATH_MAX];
afl->is_main_node = 1;
sprintf(path, "%s/is_main_node", afl->out_dir);
int fd = open(path, O_CREAT | O_RDWR, 0644);

View File

@ -31,7 +31,7 @@
void write_setup_file(afl_state_t *afl, u32 argc, char **argv) {
u8 fn[PATH_MAX];
u8 fn[PATH_MAX];
snprintf(fn, PATH_MAX, "%s/fuzzer_setup", afl->out_dir);
FILE *f = create_ffile(fn);
u32 i;

View File

@ -299,7 +299,8 @@ int main(int argc, char **argv_orig, char **envp) {
s32 opt, i, auto_sync = 0 /*, user_set_cache = 0*/;
u64 prev_queued = 0;
u32 sync_interval_cnt = 0, seek_to = 0, show_help = 0, map_size = get_map_size();
u32 sync_interval_cnt = 0, seek_to = 0, show_help = 0,
map_size = get_map_size();
u8 *extras_dir[4];
u8 mem_limit_given = 0, exit_1 = 0, debug = 0,
extras_dir_cnt = 0 /*, have_p = 0*/;
@ -326,7 +327,7 @@ int main(int argc, char **argv_orig, char **envp) {
if (get_afl_env("AFL_DEBUG")) { debug = afl->debug = 1; }
// map_size = get_map_size();
// map_size = get_map_size();
afl_state_init(afl, map_size);
afl->debug = debug;
afl_fsrv_init(&afl->fsrv);

View File

@ -252,8 +252,8 @@ static void edit_params(int argc, char **argv) {
int main(int argc, char **argv) {
s32 pid, i, status;
// u8 * ptr;
s32 pid, i, status;
// u8 * ptr;
char thecwd[PATH_MAX];
if (getenv("AFL_LD_CALLER") != NULL) {

View File

@ -1014,9 +1014,9 @@ int main(int argc, char **argv_orig, char **envp) {
DIR * dir_in, *dir_out = NULL;
struct dirent *dir_ent;
// int done = 0;
u8 infile[PATH_MAX], outfile[PATH_MAX];
u8 wait_for_gdb = 0;
// int done = 0;
u8 infile[PATH_MAX], outfile[PATH_MAX];
u8 wait_for_gdb = 0;
#if !defined(DT_REG)
struct stat statbuf;
#endif