aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2020-09-08 20:58:44 +0200
committerAndrea Fioraldi <andreafioraldi@gmail.com>2020-09-08 20:58:44 +0200
commiteb9f323d7c0252c8cb4229181c8b22dbdf113759 (patch)
tree4139fd9b343dcdcec9cd8c71a8984d167ed2b00c /src
parentfe98e2d760a343938de229a4253a151e3b7f7abb (diff)
parentab744abc4b3c90bee355807e7b6e40ba86f23e74 (diff)
downloadafl++-eb9f323d7c0252c8cb4229181c8b22dbdf113759.tar.gz
Merge branch 'dev' of github.com:vanhauser-thc/AFLplusplus into dev
Diffstat (limited to 'src')
-rw-r--r--src/afl-cc.c119
-rw-r--r--src/afl-forkserver.c6
-rw-r--r--src/afl-fuzz-init.c3
-rw-r--r--src/afl-fuzz-mutators.c4
-rw-r--r--src/afl-fuzz.c98
5 files changed, 121 insertions, 109 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index ddda3845..6bee8b38 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -1196,7 +1196,7 @@ int main(int argc, char **argv, char **envp) {
" - NGRAM-{2-16}\n"
" [GCC_PLUGIN] gcc plugin: %s%s\n"
" CLASSIC DEFAULT no yes yes no no no "
- " simple\n"
+ " yes\n"
" [GCC] simple gcc: %s%s\n"
" CLASSIC DEFAULT no no no no no no "
" no\n\n",
@@ -1270,75 +1270,88 @@ int main(int argc, char **argv, char **envp) {
" AFL_CXX: path to the C++ compiler to use\n"
" AFL_DEBUG: enable developer debugging output\n"
" AFL_DONT_OPTIMIZE: disable optimization instead of -O3\n"
- " AFL_HARDEN: adds code hardening to catch memory bugs\n"
- " AFL_INST_RATIO: percentage of branches to instrument\n"
-#if LLVM_MAJOR < 9
- " AFL_LLVM_NOT_ZERO: use cycling trace counters that skip zero\n"
-#else
- " AFL_LLVM_SKIP_NEVERZERO: do not skip zero on trace counters\n"
-#endif
- " AFL_LLVM_DICT2FILE: generate an afl dictionary based on found "
- "comparisons\n"
- " AFL_LLVM_LAF_ALL: enables all LAF splits/transforms\n"
- " AFL_LLVM_LAF_SPLIT_COMPARES: enable cascaded comparisons\n"
- " AFL_LLVM_LAF_SPLIT_COMPARES_BITW: size limit (default 8)\n"
- " AFL_LLVM_LAF_SPLIT_SWITCHES: cascaded comparisons on switches\n"
- " AFL_LLVM_LAF_SPLIT_FLOATS: cascaded comparisons on floats\n"
- " AFL_LLVM_LAF_TRANSFORM_COMPARES: cascade comparisons for string "
- "functions\n"
- " AFL_LLVM_INSTRUMENT_ALLOW/AFL_LLVM_INSTRUMENT_DENY: enable "
- "instrument allow/\n"
- " deny listing (selective instrumentation)\n"
" AFL_NO_BUILTIN: no builtins for string compare functions (for "
"libtokencap.so)\n"
" AFL_PATH: path to instrumenting pass and runtime "
"(afl-compiler-rt.*o)\n"
- " AFL_LLVM_DOCUMENT_IDS: document edge IDs given to which function "
- "(LTO only)\n"
+ " AFL_INST_RATIO: percentage of branches to instrument\n"
" AFL_QUIET: suppress verbose output\n"
+ " AFL_HARDEN: adds code hardening to catch memory bugs\n"
" AFL_USE_ASAN: activate address sanitizer\n"
" AFL_USE_CFISAN: activate control flow sanitizer\n"
" AFL_USE_MSAN: activate memory sanitizer\n"
" AFL_USE_UBSAN: activate undefined behaviour sanitizer\n");
- SAYF(
- "\nLLVM/LTO/afl-clang-fast/afl-clang-lto specific environment "
- "variables:\n"
- " AFL_LLVM_CMPLOG: log operands of comparisons (RedQueen mutator)\n"
- " AFL_LLVM_INSTRUMENT: set instrumentation mode: CLASSIC, INSTRIM, "
- "PCGUARD, LTO, CTX, NGRAM-2 ... NGRAM-16\n"
- " You can also use the old environment variables instead:\n"
- " AFL_LLVM_USE_TRACE_PC: use LLVM trace-pc-guard instrumentation\n"
- " AFL_LLVM_INSTRIM: use light weight instrumentation InsTrim\n"
- " AFL_LLVM_INSTRIM_LOOPHEAD: optimize loop tracing for speed "
- "(option to INSTRIM)\n"
- " AFL_LLVM_CTX: use context sensitive coverage (for CLASSIC and "
- "INSTRIM)\n"
- " AFL_LLVM_NGRAM_SIZE: use ngram prev_loc count coverage (for "
- "CLASSIC and INSTRIM)\n");
+ if (have_gcc_plugin)
+ SAYF(
+ "\nGCC Plugin-specific environment variables:\n"
+ " AFL_GCC_OUT_OF_LINE: disable inlined instrumentation\n"
+ " AFL_GCC_SKIP_NEVERZERO: do not skip zero on trace counters\n"
+ " AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by "
+ "filename\n");
+
+ if (have_llvm)
+ SAYF(
+ "\nLLVM/LTO/afl-clang-fast/afl-clang-lto specific environment "
+ "variables:\n"
+#if LLVM_MAJOR < 9
+ " AFL_LLVM_NOT_ZERO: use cycling trace counters that skip zero\n"
+#else
+ " AFL_LLVM_SKIP_NEVERZERO: do not skip zero on trace counters\n"
+#endif
+ " AFL_LLVM_DICT2FILE: generate an afl dictionary based on found "
+ "comparisons\n"
+ " AFL_LLVM_LAF_ALL: enables all LAF splits/transforms\n"
+ " AFL_LLVM_LAF_SPLIT_COMPARES: enable cascaded comparisons\n"
+ " AFL_LLVM_LAF_SPLIT_COMPARES_BITW: size limit (default 8)\n"
+ " AFL_LLVM_LAF_SPLIT_SWITCHES: cascaded comparisons on switches\n"
+ " AFL_LLVM_LAF_SPLIT_FLOATS: cascaded comparisons on floats\n"
+ " AFL_LLVM_LAF_TRANSFORM_COMPARES: cascade comparisons for string "
+ "functions\n"
+ " AFL_LLVM_INSTRUMENT_ALLOW/AFL_LLVM_INSTRUMENT_DENY: enable "
+ "instrument allow/\n"
+ " deny listing (selective instrumentation)\n");
+
+ if (have_llvm)
+ SAYF(
+ " AFL_LLVM_CMPLOG: log operands of comparisons (RedQueen "
+ "mutator)\n"
+ " AFL_LLVM_INSTRUMENT: set instrumentation mode:\n"
+ " CLASSIC, INSTRIM, PCGUARD, LTO, CTX, NGRAM-2 ... NGRAM-16\n"
+ " You can also use the old environment variables instead:\n"
+ " AFL_LLVM_USE_TRACE_PC: use LLVM trace-pc-guard instrumentation\n"
+ " AFL_LLVM_INSTRIM: use light weight instrumentation InsTrim\n"
+ " AFL_LLVM_INSTRIM_LOOPHEAD: optimize loop tracing for speed "
+ "(option to INSTRIM)\n"
+ " AFL_LLVM_CTX: use context sensitive coverage (for CLASSIC and "
+ "INSTRIM)\n"
+ " AFL_LLVM_NGRAM_SIZE: use ngram prev_loc count coverage (for "
+ "CLASSIC & INSTRIM)\n");
#ifdef AFL_CLANG_FLTO
- SAYF(
- "\nLTO/afl-clang-lto specific environment variables:\n"
- "AFL_LLVM_MAP_ADDR: use a fixed coverage map address (speed), e.g. "
- "0x10000\n"
- "AFL_LLVM_DOCUMENT_IDS: write all edge IDs and the corresponding "
- "functions they are in into this file\n"
- "AFL_LLVM_LTO_DONTWRITEID: don't write the highest ID used to a "
- "global var\n"
- "AFL_LLVM_LTO_STARTID: from which ID to start counting from for a "
- "bb\n"
- "AFL_REAL_LD: use this lld linker instead of the compiled in path\n"
- "\nafl-clang-lto was built with linker target \"%s\" and LTO flags "
- "\"%s\"\n"
- "If anything fails - be sure to read README.lto.md!\n",
- AFL_REAL_LD, AFL_CLANG_FLTO);
+ if (have_lto)
+ SAYF(
+ "\nLTO/afl-clang-lto specific environment variables:\n"
+ " AFL_LLVM_MAP_ADDR: use a fixed coverage map address (speed), "
+ "e.g. "
+ "0x10000\n"
+ " AFL_LLVM_DOCUMENT_IDS: write all edge IDs and the corresponding "
+ "functions\n"
+ " into this file\n"
+ " AFL_LLVM_LTO_DONTWRITEID: don't write the highest ID used to a "
+ "global var\n"
+ " AFL_LLVM_LTO_STARTID: from which ID to start counting from for "
+ "a "
+ "bb\n"
+ " AFL_REAL_LD: use this lld linker instead of the compiled in "
+ "path\n"
+ "If anything fails - be sure to read README.lto.md!\n");
#endif
}
SAYF(
- "For any information on the available instrumentations and options "
+ "\nFor any information on the available instrumentations and options "
"please \n"
"consult the README.md, especially section 3.1 about instrumenting "
"targets.\n\n");
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index c8056b9e..33b16817 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -1043,11 +1043,11 @@ fsrv_run_result_t afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
}
- if (fsrv->child_pid <= 0) {
-
+ if (fsrv->child_pid <= 0) {
+
if (*stop_soon_p) { return 0; }
FATAL("Fork server is misbehaving (OOM?)");
-
+
}
exec_ms = read_s32_timed(fsrv->fsrv_st_fd, &fsrv->child_status, timeout,
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index a5ebbcd8..29c8c6fa 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -1775,7 +1775,6 @@ int check_main_node_exists(afl_state_t *afl) {
void setup_dirs_fds(afl_state_t *afl) {
u8 *tmp;
- s32 fd;
ACTF("Setting up output directories...");
@@ -1901,7 +1900,7 @@ void setup_dirs_fds(afl_state_t *afl) {
/* Gnuplot output file. */
tmp = alloc_printf("%s/plot_data", afl->out_dir);
- fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ int fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0) { PFATAL("Unable to create '%s'", tmp); }
ck_free(tmp);
diff --git a/src/afl-fuzz-mutators.c b/src/afl-fuzz-mutators.c
index d24b7db9..c4d7233c 100644
--- a/src/afl-fuzz-mutators.c
+++ b/src/afl-fuzz-mutators.c
@@ -93,9 +93,9 @@ void setup_custom_mutators(afl_state_t *afl) {
}
- struct custom_mutator *mutator = load_custom_mutator_py(afl, module_name);
+ struct custom_mutator *m = load_custom_mutator_py(afl, module_name);
afl->custom_mutators_count++;
- list_append(&afl->custom_mutator_list, mutator);
+ list_append(&afl->custom_mutator_list, m);
}
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 5b96ef45..9196d78b 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -698,7 +698,7 @@ int main(int argc, char **argv_orig, char **envp) {
afl->swarm_now = 0;
if (afl->limit_time_puppet == 0) { afl->key_puppet = 1; }
- int i;
+ int j;
int tmp_swarm = 0;
if (afl->g_now > afl->g_max) { afl->g_now = 0; }
@@ -711,70 +711,70 @@ int main(int argc, char **argv_orig, char **envp) {
double total_puppet_temp = 0.0;
afl->swarm_fitness[tmp_swarm] = 0.0;
- for (i = 0; i < operator_num; ++i) {
+ for (j = 0; j < operator_num; ++j) {
- afl->stage_finds_puppet[tmp_swarm][i] = 0;
- afl->probability_now[tmp_swarm][i] = 0.0;
- afl->x_now[tmp_swarm][i] =
+ afl->stage_finds_puppet[tmp_swarm][j] = 0;
+ afl->probability_now[tmp_swarm][j] = 0.0;
+ afl->x_now[tmp_swarm][j] =
((double)(random() % 7000) * 0.0001 + 0.1);
- total_puppet_temp += afl->x_now[tmp_swarm][i];
- afl->v_now[tmp_swarm][i] = 0.1;
- afl->L_best[tmp_swarm][i] = 0.5;
- afl->G_best[i] = 0.5;
- afl->eff_best[tmp_swarm][i] = 0.0;
+ total_puppet_temp += afl->x_now[tmp_swarm][j];
+ afl->v_now[tmp_swarm][j] = 0.1;
+ afl->L_best[tmp_swarm][j] = 0.5;
+ afl->G_best[j] = 0.5;
+ afl->eff_best[tmp_swarm][j] = 0.0;
}
- for (i = 0; i < operator_num; ++i) {
+ for (j = 0; j < operator_num; ++j) {
- afl->stage_cycles_puppet_v2[tmp_swarm][i] =
- afl->stage_cycles_puppet[tmp_swarm][i];
- afl->stage_finds_puppet_v2[tmp_swarm][i] =
- afl->stage_finds_puppet[tmp_swarm][i];
- afl->x_now[tmp_swarm][i] =
- afl->x_now[tmp_swarm][i] / total_puppet_temp;
+ afl->stage_cycles_puppet_v2[tmp_swarm][j] =
+ afl->stage_cycles_puppet[tmp_swarm][j];
+ afl->stage_finds_puppet_v2[tmp_swarm][j] =
+ afl->stage_finds_puppet[tmp_swarm][j];
+ afl->x_now[tmp_swarm][j] =
+ afl->x_now[tmp_swarm][j] / total_puppet_temp;
}
double x_temp = 0.0;
- for (i = 0; i < operator_num; ++i) {
+ for (j = 0; j < operator_num; ++j) {
- afl->probability_now[tmp_swarm][i] = 0.0;
- afl->v_now[tmp_swarm][i] =
- afl->w_now * afl->v_now[tmp_swarm][i] +
+ afl->probability_now[tmp_swarm][j] = 0.0;
+ afl->v_now[tmp_swarm][j] =
+ afl->w_now * afl->v_now[tmp_swarm][j] +
RAND_C *
- (afl->L_best[tmp_swarm][i] - afl->x_now[tmp_swarm][i]) +
- RAND_C * (afl->G_best[i] - afl->x_now[tmp_swarm][i]);
+ (afl->L_best[tmp_swarm][j] - afl->x_now[tmp_swarm][j]) +
+ RAND_C * (afl->G_best[j] - afl->x_now[tmp_swarm][j]);
- afl->x_now[tmp_swarm][i] += afl->v_now[tmp_swarm][i];
+ afl->x_now[tmp_swarm][j] += afl->v_now[tmp_swarm][j];
- if (afl->x_now[tmp_swarm][i] > v_max) {
+ if (afl->x_now[tmp_swarm][j] > v_max) {
- afl->x_now[tmp_swarm][i] = v_max;
+ afl->x_now[tmp_swarm][j] = v_max;
- } else if (afl->x_now[tmp_swarm][i] < v_min) {
+ } else if (afl->x_now[tmp_swarm][j] < v_min) {
- afl->x_now[tmp_swarm][i] = v_min;
+ afl->x_now[tmp_swarm][j] = v_min;
}
- x_temp += afl->x_now[tmp_swarm][i];
+ x_temp += afl->x_now[tmp_swarm][j];
}
- for (i = 0; i < operator_num; ++i) {
+ for (j = 0; j < operator_num; ++j) {
- afl->x_now[tmp_swarm][i] = afl->x_now[tmp_swarm][i] / x_temp;
- if (likely(i != 0)) {
+ afl->x_now[tmp_swarm][j] = afl->x_now[tmp_swarm][j] / x_temp;
+ if (likely(j != 0)) {
- afl->probability_now[tmp_swarm][i] =
- afl->probability_now[tmp_swarm][i - 1] +
- afl->x_now[tmp_swarm][i];
+ afl->probability_now[tmp_swarm][j] =
+ afl->probability_now[tmp_swarm][j - 1] +
+ afl->x_now[tmp_swarm][j];
} else {
- afl->probability_now[tmp_swarm][i] = afl->x_now[tmp_swarm][i];
+ afl->probability_now[tmp_swarm][j] = afl->x_now[tmp_swarm][j];
}
@@ -789,13 +789,13 @@ int main(int argc, char **argv_orig, char **envp) {
}
- for (i = 0; i < operator_num; ++i) {
+ for (j = 0; j < operator_num; ++j) {
- afl->core_operator_finds_puppet[i] = 0;
- afl->core_operator_finds_puppet_v2[i] = 0;
- afl->core_operator_cycles_puppet[i] = 0;
- afl->core_operator_cycles_puppet_v2[i] = 0;
- afl->core_operator_cycles_puppet_v3[i] = 0;
+ afl->core_operator_finds_puppet[j] = 0;
+ afl->core_operator_finds_puppet_v2[j] = 0;
+ afl->core_operator_cycles_puppet[j] = 0;
+ afl->core_operator_cycles_puppet_v2[j] = 0;
+ afl->core_operator_cycles_puppet_v3[j] = 0;
}
@@ -1010,10 +1010,10 @@ int main(int argc, char **argv_orig, char **envp) {
u8 *afl_preload = getenv("AFL_PRELOAD");
u8 *buf;
- s32 i, afl_preload_size = strlen(afl_preload);
- for (i = 0; i < afl_preload_size; ++i) {
+ s32 j, afl_preload_size = strlen(afl_preload);
+ for (j = 0; j < afl_preload_size; ++j) {
- if (afl_preload[i] == ',') {
+ if (afl_preload[j] == ',') {
PFATAL(
"Comma (',') is not allowed in AFL_PRELOAD when -Q is "
@@ -1188,10 +1188,10 @@ int main(int argc, char **argv_orig, char **envp) {
if (!afl->fsrv.out_file) {
- u32 i = optind + 1;
- while (argv[i]) {
+ u32 j = optind + 1;
+ while (argv[j]) {
- u8 *aa_loc = strstr(argv[i], "@@");
+ u8 *aa_loc = strstr(argv[j], "@@");
if (aa_loc && !afl->fsrv.out_file) {
@@ -1214,7 +1214,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
- ++i;
+ ++j;
}