mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-23 23:10:57 +07:00
util: avoid divide by zero FPE
In early userspace, if kernel initialization happens extremely quickly, a call to systemd-timestamp can potentially result in division by zero. Ensure that the check in timespec_load, which only makes sense if tv_sec is greater than zero, is guarded by this condition.
This commit is contained in:
parent
6827101ab4
commit
49371bb50e
@ -148,7 +148,8 @@ usec_t timespec_load(const struct timespec *ts) {
|
||||
ts->tv_nsec == (long) -1)
|
||||
return (usec_t) -1;
|
||||
|
||||
if (USEC_PER_SEC > ((UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / (usec_t) ts->tv_sec))
|
||||
if (ts->tv_sec > 0 &&
|
||||
USEC_PER_SEC > ((UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / (usec_t) ts->tv_sec))
|
||||
return (usec_t) -1;
|
||||
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user