print a completed UI screen on exit without bugs :)
MODIFY
include/afl-fuzz.h
include/afl-fuzz.h
@@ -331,7 +331,8 @@ typedef struct afl_state {
really makes no sense to haul them around as function parameters. */
u64 limit_time_puppet, orig_hit_cnt_puppet, last_limit_time_start,
tmp_pilot_time, total_pacemaker_time, total_puppet_find, temp_puppet_find,
- most_time_key, most_time, most_execs_key, most_execs, old_hit_count;
+ most_time_key, most_time, most_execs_key, most_execs, old_hit_count,
+ force_ui_update;
MOpt_globals_t mopt_globals_core, mopt_globals_pilot;

MODIFY
src/afl-fuzz-globals.c
src/afl-fuzz-globals.c
@@ -139,119 +139,136 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
int i = 0, match = 0;
while (match == 0 && afl_environment_variables[i] != NULL) {
- size_t afl_environment_variable_len = strlen(afl_environment_variables[i]);
+ size_t afl_environment_variable_len =
+ strlen(afl_environment_variables[i]);
if (strncmp(env, afl_environment_variables[i],
afl_environment_variable_len) == 0 &&
env[afl_environment_variable_len] == '=') {
match = 1;
- if (!strncmp(env, "AFL_SKIP_CPUFREQ",
- afl_environment_variable_len)) {
+ if (!strncmp(env, "AFL_SKIP_CPUFREQ", afl_environment_variable_len)) {
afl->afl_env.afl_skip_cpufreq = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_EXIT_WHEN_DONE",
+
afl_environment_variable_len)) {
afl->afl_env.afl_exit_when_done = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_NO_AFFINITY",
+
afl_environment_variable_len)) {
afl->afl_env.afl_no_affinity = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_SKIP_CRASHES",
+
afl_environment_variable_len)) {
afl->afl_env.afl_skip_crashes = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_HANG_TMOUT",
+
afl_environment_variable_len)) {
afl->afl_env.afl_hang_tmout = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_SKIP_BIN_CHECK",
+
afl_environment_variable_len)) {
afl->afl_env.afl_skip_bin_check = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_DUMB_FORKSRV",
+
afl_environment_variable_len)) {
afl->afl_env.afl_dumb_forksrv = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_IMPORT_FIRST",
+
afl_environment_variable_len)) {
afl->afl_env.afl_import_first = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_CUSTOM_MUTATOR_ONLY",
+
afl_environment_variable_len)) {
afl->afl_env.afl_custom_mutator_only = get_afl_env(env) ? 1 : 0;
- } else if (!strncmp(env, "AFL_NO_UI",
- afl_environment_variable_len)) {
+ } else if (!strncmp(env, "AFL_NO_UI", afl_environment_variable_len)) {
afl->afl_env.afl_no_ui = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_FORCE_UI",
+
afl_environment_variable_len)) {
afl->afl_env.afl_force_ui = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES",
+
afl_environment_variable_len)) {
afl->afl_env.afl_i_dont_care_about_missing_crashes =
get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_BENCH_JUST_ONE",
+
afl_environment_variable_len)) {
afl->afl_env.afl_bench_just_one = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_BENCH_UNTIL_CRASH",
+
afl_environment_variable_len)) {
afl->afl_env.afl_bench_until_crash = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_DEBUG_CHILD_OUTPUT",
+
afl_environment_variable_len)) {
afl->afl_env.afl_debug_child_output = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_AUTORESUME",
+
afl_environment_variable_len)) {
afl->afl_env.afl_autoresume = get_afl_env(env) ? 1 : 0;
} else if (!strncmp(env, "AFL_TMPDIR",
+
afl_environment_variable_len)) {
afl->afl_env.afl_tmpdir = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_POST_LIBRARY",
+
afl_environment_variable_len)) {
afl->afl_env.afl_post_library = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_CUSTOM_MUTATOR_LIBRARY",
+
afl_environment_variable_len)) {
afl->afl_env.afl_custom_mutator_library = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_PYTHON_MODULE",
+
afl_environment_variable_len)) {
afl->afl_env.afl_python_module = (u8 *)get_afl_env(env);
- } else if (!strncmp(env, "AFL_PATH",
- afl_environment_variable_len)) {
+ } else if (!strncmp(env, "AFL_PATH", afl_environment_variable_len)) {
afl->afl_env.afl_path = (u8 *)get_afl_env(env);
} else if (!strncmp(env, "AFL_PRELOAD",
+
afl_environment_variable_len)) {
afl->afl_env.afl_preload = (u8 *)get_afl_env(env);

MODIFY
src/afl-fuzz-stats.c
src/afl-fuzz-stats.c
@@ -206,7 +206,7 @@ void show_stats(afl_state_t *afl) {
/* If not enough time has passed since last UI update, bail out. */
- if (cur_ms - last_ms < 1000 / UI_TARGET_HZ) return;
+ if (cur_ms - last_ms < 1000 / UI_TARGET_HZ && !afl->force_ui_update) return;
/* Check if we're past the 10 minute mark. */
@@ -484,7 +484,7 @@ void show_stats(afl_state_t *afl) {
}
- SAYF(bV bSTOP " stage execs : " cRST "%-20s " bSTG bV bSTOP, tmp);
+ SAYF(bV bSTOP " stage execs : " cRST "%-21s" bSTG bV bSTOP, tmp);
sprintf(tmp, "%s (%0.02f%%)", DI(afl->queued_with_cov),
((double)afl->queued_with_cov) * 100 / afl->queued_paths);

MODIFY
src/afl-fuzz.c
src/afl-fuzz.c
@@ -1074,7 +1074,7 @@ int main(int argc, char **argv_orig, char **envp) {
skipped_fuzz = fuzz_one(afl);
- if (!afl->stop_soon && afl->sync_id && !skipped_fuzz) {
+ if (!skipped_fuzz && !afl->stop_soon && afl->sync_id) {
if (!(sync_interval_cnt++ % SYNC_INTERVAL)) sync_fuzzers(afl);
@@ -1145,6 +1145,9 @@ int main(int argc, char **argv_orig, char **envp) {
stop_fuzzing:
+ afl->force_ui_update = 1; // ensure the screen is reprinted
+ show_stats(afl); // print the screen one last time
+
SAYF(CURSOR_SHOW cLRD "\n\n+++ Testing aborted %s +++\n" cRST,
afl->stop_soon == 2 ? "programmatically" : "by user");

print a completed UI screen on exit without bugs :)