Skip to content

Commit 1931851

Browse files
committed
better defaults
1 parent de1a50e commit 1931851

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/libafl/src/events/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,11 @@ where
482482
};
483483
let cur = current_time();
484484
// default to 0 here to avoid crashes on clock skew
485-
if cur.saturating_sub(*last_report_time) > monitor_timeout {
485+
if cur
486+
.checked_sub(*last_report_time)
487+
.unwrap_or(monitor_timeout)
488+
>= monitor_timeout
489+
{
486490
// report_progress sets a new `last_report_time` internally.
487491
reporter.report_progress(state)?;
488492
}

crates/libafl/src/monitors/stats/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ impl ClientStats {
203203
/// We got new information about executions for this client, insert them.
204204
#[cfg(feature = "afl_exec_sec")]
205205
pub fn update_executions(&mut self, executions: u64, cur_time: Duration) {
206-
let diff = cur_time.saturating_sub(self.last_window_time).as_secs();
207-
if diff > CLIENT_STATS_TIME_WINDOW_SECS {
206+
let diff = cur_time
207+
.checked_sub(self.last_window_time)
208+
.map_or(CLIENT_STATS_TIME_WINDOW_SECS, |d| d.as_secs());
209+
if diff >= CLIENT_STATS_TIME_WINDOW_SECS {
208210
let _: f64 = self.execs_per_sec(cur_time);
209211
self.last_window_time = cur_time;
210212
self.last_window_executions = self.executions;

0 commit comments

Comments
 (0)