mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
linux(4): Prevent time_t overflows on i386.
As native i386 time_t is still 32-bit, check that the user-provided 64-bit tv_sec value fits to the kernel time_t, return EOVERFLOW if not. MFC after: 2 weeks
This commit is contained in:
parent
1579b320f1
commit
3dc2a06752
1 changed files with 5 additions and 0 deletions
|
|
@ -177,6 +177,11 @@ int
|
|||
linux_to_native_timespec64(struct timespec *ntp, struct l_timespec64 *ltp64)
|
||||
{
|
||||
|
||||
#if defined(__i386__)
|
||||
/* i386 time_t is still 32-bit */
|
||||
if (ltp64->tv_sec > INT_MAX || ltp64->tv_sec < INT_MIN)
|
||||
return (EOVERFLOW);
|
||||
#endif
|
||||
/* Zero out the padding in compat mode. */
|
||||
ntp->tv_nsec = ltp64->tv_nsec & 0xFFFFFFFFUL;
|
||||
ntp->tv_sec = ltp64->tv_sec;
|
||||
|
|
|
|||
Loading…
Reference in a new issue