From 908b132f04ca82931a91699d3ecd7e2fa8e02ea2 Mon Sep 17 00:00:00 2001 From: nekluu Date: Fri, 30 Jan 2026 06:41:13 +0300 Subject: [PATCH] fix(poll): handle overflow in ppoll timeout --- src/header/poll/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/header/poll/mod.rs b/src/header/poll/mod.rs index bacebf84ef..21c9397b2b 100644 --- a/src/header/poll/mod.rs +++ b/src/header/poll/mod.rs @@ -167,8 +167,11 @@ pub unsafe extern "C" fn ppoll( -1 } else { let tmo = unsafe { &*tmo_p }; - //TODO: handle overflow - ((tmo.tv_sec as c_int) * 1000) + ((tmo.tv_nsec as c_int) / 1000000) + if tmo.tv_sec > (c_int::MAX / 1000) as _ { + c_int::MAX + } else { + ((tmo.tv_sec as c_int) * 1000) + ((tmo.tv_nsec as c_int) / 1000000) + } }; trace_expr!( poll_epoll(