From 1fc5ba63fa3483b69db074322cb26fb050d39ac4 Mon Sep 17 00:00:00 2001 From: s1341 Date: Thu, 28 Mar 2024 17:50:12 +0200 Subject: [PATCH] batch_timeout: fix overflowing subtraction (#1976) --- libafl/src/executors/hooks/timer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libafl/src/executors/hooks/timer.rs b/libafl/src/executors/hooks/timer.rs index e6109e6470..632a82dbab 100644 --- a/libafl/src/executors/hooks/timer.rs +++ b/libafl/src/executors/hooks/timer.rs @@ -324,10 +324,10 @@ impl TimerStruct { pub fn unset_timer(&mut self) { if self.batch_mode { unsafe { - let elapsed = current_time() - self.tmout_start_time; + let elapsed = current_time().saturating_sub(self.tmout_start_time); // elapsed may be > than tmout in case of received but ingored signal if elapsed > self.exec_tmout - || self.exec_tmout - elapsed < self.avg_exec_time * self.avg_mul_k + || self.exec_tmout.saturating_sub(elapsed) < self.avg_exec_time * self.avg_mul_k { let disarmed: libc::itimerspec = zeroed(); libc::timer_settime(self.timerid, 0, addr_of!(disarmed), null_mut());