diff options
| author | Hauke Mehrtens | 2026-04-08 22:37:47 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-18 22:06:41 +0000 |
| commit | 3c566439b634531cca150e550e7368ff07de864d (patch) | |
| tree | a85d3285f1f0dc8fc81fd29401afcefcfc7e5d5f | |
| parent | da9183de3707f3bf9a11d36d1ed3a26c1044d902 (diff) | |
| download | libubox-3c566439b634531cca150e550e7368ff07de864d.tar.gz | |
usock: fix off-by-one in nanosecond normalization in poll_restart()
When tv_nsec equals exactly 1000000000 (1 second), the > comparison
misses this case, leaving an invalid timespec value that could cause
incorrect timeout calculations. Use >= to properly normalize, matching
the correct pattern already used in usock_inet_timeout().
Link: https://github.com/openwrt/libubox/pull/42
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit e7c13bf8cbca063e0975c5e57abc2d704e23548c)
| -rw-r--r-- | usock.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -112,7 +112,7 @@ static int poll_restart(struct pollfd *fds, int nfds, int timeout) clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_nsec += msec * 1000000; - if (ts.tv_nsec > 1000000000) { + if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; } |