about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@ispras.ru>2023-03-02 08:10:47 +0300
committerRich Felker <dalias@aerifal.cx>2023-03-02 20:00:45 -0500
commit8949da7ab1c0dbf801e8bc78f0c0adc625020f75 (patch)
tree58b1ebb9d65e8af3d15ae31b11d2e4682a1c6198 /src
parent3281047cfca0f3848d0613e3c0d19d41b0531564 (diff)
downloadmusl-8949da7ab1c0dbf801e8bc78f0c0adc625020f75.tar.gz
musl-8949da7ab1c0dbf801e8bc78f0c0adc625020f75.tar.xz
musl-8949da7ab1c0dbf801e8bc78f0c0adc625020f75.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/select/select.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/select/select.c b/src/select/select.c
index 8a786884..f1d72863 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -33,6 +33,7 @@ int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict
 			((syscall_arg_t[]){ 0, _NSIG/8 }));
 	if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
 		return __syscall_ret(r);
+	s = CLAMP(s);
 #endif
 #ifdef SYS_select
 	return syscall_cp(SYS_select, n, rfds, wfds, efds,