diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-17 17:10:31 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-04-17 17:10:31 +0200 |
commit | 6500d123d01af895d2b8eae1a36e553a1f75e211 (patch) | |
tree | 3b176a4418f8cc6565c729821eb4a9283bc4cb75 | |
parent | 53772869bc4ecfe68ac8d53c50a6057e7872df06 (diff) | |
download | busybox-w32-6500d123d01af895d2b8eae1a36e553a1f75e211.tar.gz busybox-w32-6500d123d01af895d2b8eae1a36e553a1f75e211.tar.bz2 busybox-w32-6500d123d01af895d2b8eae1a36e553a1f75e211.zip |
udhcp: make arpping code resistant to time jumps
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/arpping.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index ff6347847..b43e52e96 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c | |||
@@ -118,8 +118,13 @@ int FAST_FUNC arpping(uint32_t test_nip, | |||
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | timeout_ms -= (unsigned)monotonic_ms() - prevTime; | 121 | timeout_ms -= (unsigned)monotonic_ms() - prevTime + 1; |
122 | } while (timeout_ms > 0); | 122 | |
123 | /* We used to check "timeout_ms > 0", but | ||
124 | * this is more under/overflow-resistant | ||
125 | * (people did see overflows here when system time jumps): | ||
126 | */ | ||
127 | } while ((unsigned)timeout_ms <= 2000); | ||
123 | 128 | ||
124 | ret: | 129 | ret: |
125 | close(s); | 130 | close(s); |