Merge branch 'time' into 'master'

fix: handle integer overflow

See merge request redox-os/relibc!1086
This commit is contained in:
Jeremy Soller
2026-03-13 19:03:12 -06:00
+6 -2
View File
@@ -131,8 +131,12 @@ pub fn select_epoll(
} else {
match timeout {
Some(timeout) => {
//TODO: Check for overflow
((timeout.tv_sec as c_int) * 1000) + ((timeout.tv_usec as c_int) / 1000)
let sec_ms = (timeout.tv_sec as c_int).checked_mul(1000);
let usec_ms = (timeout.tv_usec as c_int) / 1000;
match sec_ms.and_then(|s| s.checked_add(usec_ms)) {
Some(s) => s as c_int,
None => c_int::MAX,
}
}
None => -1,
}