mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-18 12:48:06 +00:00
Merge branch 'dev' of github.com:AFLplusplus/AFLplusplus into dev
This commit is contained in:
@ -610,12 +610,12 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
|
||||
|
||||
if (!time_ms) {
|
||||
|
||||
kill(fsrv->fsrv_pid, fsrv->kill_signal);
|
||||
if (fsrv->fsrv_pid > 0) { kill(fsrv->fsrv_pid, fsrv->kill_signal); }
|
||||
|
||||
} else if (time_ms > fsrv->init_tmout) {
|
||||
|
||||
fsrv->last_run_timed_out = 1;
|
||||
kill(fsrv->fsrv_pid, fsrv->kill_signal);
|
||||
if (fsrv->fsrv_pid > 0) { kill(fsrv->fsrv_pid, fsrv->kill_signal); }
|
||||
|
||||
} else {
|
||||
|
||||
@ -1248,7 +1248,7 @@ fsrv_run_result_t afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
|
||||
/* If there was no response from forkserver after timeout seconds,
|
||||
we kill the child. The forkserver should inform us afterwards */
|
||||
|
||||
kill(fsrv->child_pid, fsrv->kill_signal);
|
||||
if (fsrv->child_pid > 0) { kill(fsrv->child_pid, fsrv->kill_signal); }
|
||||
fsrv->last_run_timed_out = 1;
|
||||
if (read(fsrv->fsrv_st_fd, &fsrv->child_status, 4) < 4) { exec_ms = 0; }
|
||||
|
||||
|
@ -2815,43 +2815,6 @@ void check_binary(afl_state_t *afl, u8 *fname) {
|
||||
|
||||
}
|
||||
|
||||
/* Trim and possibly create a banner for the run. */
|
||||
|
||||
void fix_up_banner(afl_state_t *afl, u8 *name) {
|
||||
|
||||
if (!afl->use_banner) {
|
||||
|
||||
if (afl->sync_id) {
|
||||
|
||||
afl->use_banner = afl->sync_id;
|
||||
|
||||
} else {
|
||||
|
||||
u8 *trim = strrchr(name, '/');
|
||||
if (!trim) {
|
||||
|
||||
afl->use_banner = name;
|
||||
|
||||
} else {
|
||||
|
||||
afl->use_banner = trim + 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (strlen(afl->use_banner) > 32) {
|
||||
|
||||
u8 *tmp = ck_alloc(36);
|
||||
sprintf(tmp, "%.32s...", afl->use_banner);
|
||||
afl->use_banner = tmp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Check if we're on TTY. */
|
||||
|
||||
void check_if_tty(afl_state_t *afl) {
|
||||
|
@ -291,8 +291,6 @@ static void write_with_gap(afl_state_t *afl, u8 *mem, u32 len, u32 skip_at,
|
||||
u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem,
|
||||
u32 handicap, u8 from_queue) {
|
||||
|
||||
if (unlikely(afl->shm.cmplog_mode)) { q->exec_cksum = 0; }
|
||||
|
||||
u8 fault = 0, new_bits = 0, var_detected = 0, hnb = 0,
|
||||
first_run = (q->exec_cksum == 0);
|
||||
u64 start_us, stop_us, diff_us;
|
||||
@ -300,6 +298,8 @@ u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem,
|
||||
u32 use_tmout = afl->fsrv.exec_tmout;
|
||||
u8 *old_sn = afl->stage_name;
|
||||
|
||||
if (unlikely(afl->shm.cmplog_mode)) { q->exec_cksum = 0; }
|
||||
|
||||
/* Be a bit more generous about timeouts when resuming sessions, or when
|
||||
trying to calibrate already-added finds. This helps avoid trouble due
|
||||
to intermittent latency. */
|
||||
@ -343,6 +343,32 @@ u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem,
|
||||
|
||||
}
|
||||
|
||||
/* we need a dummy run if this is LTO + cmplog */
|
||||
if (unlikely(afl->shm.cmplog_mode)) {
|
||||
|
||||
write_to_testcase(afl, use_mem, q->len);
|
||||
|
||||
fault = fuzz_run_target(afl, &afl->fsrv, use_tmout);
|
||||
|
||||
/* afl->stop_soon is set by the handler for Ctrl+C. When it's pressed,
|
||||
we want to bail out quickly. */
|
||||
|
||||
if (afl->stop_soon || fault != afl->crash_mode) { goto abort_calibration; }
|
||||
|
||||
if (!afl->non_instrumented_mode && !afl->stage_cur &&
|
||||
!count_bytes(afl, afl->fsrv.trace_bits)) {
|
||||
|
||||
fault = FSRV_RUN_NOINST;
|
||||
goto abort_calibration;
|
||||
|
||||
}
|
||||
|
||||
#ifdef INTROSPECTION
|
||||
if (unlikely(!q->bitsmap_size)) q->bitsmap_size = afl->bitsmap_size;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (q->exec_cksum) {
|
||||
|
||||
memcpy(afl->first_trace, afl->fsrv.trace_bits, afl->fsrv.map_size);
|
||||
|
@ -441,9 +441,10 @@ void show_stats(afl_state_t *afl) {
|
||||
u64 cur_ms;
|
||||
u32 t_bytes, t_bits;
|
||||
|
||||
u32 banner_len, banner_pad;
|
||||
u8 tmp[256];
|
||||
u8 time_tmp[64];
|
||||
static u8 banner[128];
|
||||
u32 banner_len, banner_pad;
|
||||
u8 tmp[256];
|
||||
u8 time_tmp[64];
|
||||
|
||||
u8 val_buf[8][STRINGIFY_VAL_SIZE_MAX];
|
||||
#define IB(i) (val_buf[(i)])
|
||||
@ -656,26 +657,34 @@ void show_stats(afl_state_t *afl) {
|
||||
}
|
||||
|
||||
/* Let's start by drawing a centered banner. */
|
||||
if (unlikely(!banner[0])) {
|
||||
|
||||
banner_len = (afl->crash_mode ? 24 : 22) + strlen(VERSION) +
|
||||
strlen(afl->use_banner) + strlen(afl->power_name) + 3 + 5;
|
||||
banner_pad = (79 - banner_len) / 2;
|
||||
memset(tmp, ' ', banner_pad);
|
||||
char *si = "";
|
||||
if (afl->sync_id) { si = afl->sync_id; }
|
||||
memset(banner, 0, sizeof(banner));
|
||||
banner_len = (afl->crash_mode ? 20 : 18) + strlen(VERSION) + strlen(si) +
|
||||
strlen(afl->power_name) + 4 + 6;
|
||||
|
||||
#ifdef HAVE_AFFINITY
|
||||
sprintf(
|
||||
tmp + banner_pad,
|
||||
"%s " cLCY VERSION cLGN " (%s) " cPIN "[%s]" cBLU " {%d}",
|
||||
afl->crash_mode ? cPIN "peruvian were-rabbit" : cYEL "american fuzzy lop",
|
||||
afl->use_banner, afl->power_name, afl->cpu_aff);
|
||||
#else
|
||||
sprintf(
|
||||
tmp + banner_pad, "%s " cLCY VERSION cLGN " (%s) " cPIN "[%s]",
|
||||
afl->crash_mode ? cPIN "peruvian were-rabbit" : cYEL "american fuzzy lop",
|
||||
afl->use_banner, afl->power_name);
|
||||
#endif /* HAVE_AFFINITY */
|
||||
if (strlen(afl->use_banner) + banner_len > 75) {
|
||||
|
||||
SAYF("\n%s\n", tmp);
|
||||
afl->use_banner += (strlen(afl->use_banner) + banner_len) - 76;
|
||||
memset(afl->use_banner, '.', 3);
|
||||
|
||||
}
|
||||
|
||||
banner_len += strlen(afl->use_banner);
|
||||
banner_pad = (79 - banner_len) / 2;
|
||||
memset(banner, ' ', banner_pad);
|
||||
|
||||
sprintf(banner + banner_pad,
|
||||
"%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s]",
|
||||
afl->crash_mode ? cPIN "peruvian were-rabbit"
|
||||
: cYEL "american fuzzy lop",
|
||||
si, afl->use_banner, afl->power_name);
|
||||
|
||||
}
|
||||
|
||||
SAYF("\n%s\n", banner);
|
||||
|
||||
/* "Handy" shortcuts for drawing boxes... */
|
||||
|
||||
|
@ -1189,7 +1189,17 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
if (afl->sync_id) { fix_up_sync(afl); }
|
||||
if (afl->sync_id) {
|
||||
|
||||
if (strlen(afl->sync_id) > 24) {
|
||||
|
||||
FATAL("sync_id max length is 24 characters");
|
||||
|
||||
}
|
||||
|
||||
fix_up_sync(afl);
|
||||
|
||||
}
|
||||
|
||||
if (!strcmp(afl->in_dir, afl->out_dir)) {
|
||||
|
||||
@ -1218,6 +1228,8 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
if (unlikely(afl->afl_env.afl_statsd)) { statsd_setup_format(afl); }
|
||||
|
||||
if (!afl->use_banner) { afl->use_banner = argv[optind]; }
|
||||
|
||||
if (strchr(argv[optind], '/') == NULL && !afl->unicorn_mode) {
|
||||
|
||||
WARNF(cLRD
|
||||
@ -1486,9 +1498,6 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
}
|
||||
|
||||
save_cmdline(afl, argc, argv);
|
||||
|
||||
fix_up_banner(afl, argv[optind]);
|
||||
|
||||
check_if_tty(afl);
|
||||
if (afl->afl_env.afl_force_ui) { afl->not_on_tty = 0; }
|
||||
|
||||
|
@ -242,9 +242,14 @@ static u32 write_results_to_file(afl_forkserver_t *fsrv, u8 *outfile) {
|
||||
if (cmin_mode &&
|
||||
(fsrv->last_run_timed_out || (!caa && child_crashed != cco))) {
|
||||
|
||||
// create empty file to prevent error messages in afl-cmin
|
||||
fd = open(outfile, O_WRONLY | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
|
||||
close(fd);
|
||||
if (strcmp(outfile, "-")) {
|
||||
|
||||
// create empty file to prevent error messages in afl-cmin
|
||||
fd = open(outfile, O_WRONLY | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user