select: fix 64-bit timeout truncation on pre-time64 kernels
authorAlexey Izbyshev <izbyshev@ispras.ru>
Thu, 2 Mar 2023 05:10:47 +0000 (08:10 +0300)
committerRich Felker <dalias@aerifal.cx>
Fri, 3 Mar 2023 01:00:45 +0000 (20:00 -0500)
commit8949da7ab1c0dbf801e8bc78f0c0adc625020f75
tree58b1ebb9d65e8af3d15ae31b11d2e4682a1c6198
parent3281047cfca0f3848d0613e3c0d19d41b0531564
select: fix 64-bit timeout truncation on pre-time64 kernels

If the (normalized) timeout passed to select exceeds INT_MAX seconds on
an arch with SYS_pselect6_time64 and the kernel is too old to support
time64 syscalls, the timeout is implicitly converted to (32-bit) long on
the fallback path, losing its upper 32 bits and potentially becoming a
small positive value, violating the intended semantics, or even
a negative value, causing the fallback syscall failure. Fix this by
saturating the timeout at INT_MAX as done in other time64 fallback
cases.
src/select/select.c