Skip to content

Commit 72d5443

Browse files
Use libc::time_t::MAX instead of i64::MAX
1 parent a68867f commit 72d5443

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/uucore/src/lib/features/process.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ impl ChildExt for Child {
159159
}
160160

161161
// Convert Duration to timespec for sigtimedwait
162-
// Cap at i64::MAX to prevent overflow
163-
const MAX_TIMESPEC_SECONDS: u64 = i64::MAX as u64;
162+
// Cap at time_t::MAX to prevent overflow (time_t is i32 on 32-bit, i64 on 64-bit)
163+
const MAX_TIMESPEC_SECONDS: u64 = libc::time_t::MAX as u64;
164164
let timeout_spec = if timeout.as_secs() >= MAX_TIMESPEC_SECONDS {
165165
libc::timespec {
166-
tv_sec: i64::MAX,
166+
tv_sec: libc::time_t::MAX,
167167
tv_nsec: 0,
168168
}
169169
} else {
@@ -268,11 +268,11 @@ impl ChildExt for Child {
268268
// Calculate timeout and deadline
269269
// Use checked_add to prevent overflow with very large timeouts
270270
let deadline = Instant::now().checked_add(timeout);
271-
// Cap timeout at i64::MAX to prevent overflow in timespec conversion
272-
const MAX_TIMESPEC_SECONDS: u64 = i64::MAX as u64;
271+
// Cap timeout at time_t::MAX to prevent overflow in timespec conversion
272+
const MAX_TIMESPEC_SECONDS: u64 = libc::time_t::MAX as u64;
273273
let timeout_spec = if timeout.as_secs() >= MAX_TIMESPEC_SECONDS {
274274
Some(libc::timespec {
275-
tv_sec: i64::MAX,
275+
tv_sec: libc::time_t::MAX,
276276
tv_nsec: 0,
277277
})
278278
} else {

0 commit comments

Comments
 (0)