From 6500d123d01af895d2b8eae1a36e553a1f75e211 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 17:10:31 +0200 Subject: udhcp: make arpping code resistant to time jumps Signed-off-by: Denys Vlasenko --- networking/udhcp/arpping.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'networking/udhcp/arpping.c') 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, break; } } - timeout_ms -= (unsigned)monotonic_ms() - prevTime; - } while (timeout_ms > 0); + timeout_ms -= (unsigned)monotonic_ms() - prevTime + 1; + + /* We used to check "timeout_ms > 0", but + * this is more under/overflow-resistant + * (people did see overflows here when system time jumps): + */ + } while ((unsigned)timeout_ms <= 2000); ret: close(s); -- cgit v1.2.3