Hi,
I'm attaching a patch for way too long wait on poll() during arpping
after IP address acquiring over DHCP.
It happens on a platform which starts with Epoch time. Then, at some
point, a correct time source appears, and an actual time is set.
If an actual time is set during wait on poll(), computing of a timeout
overflows on unsigned type. The patch just changes types to stay with
long long computing.
Before applying the patch the side effect of setting an actual time is
close to hangup - with no IP address assigned. After applying the patch
the side effect of time change is that poll() might wait shorter than
desired 2 seconds in case of socket activity.
I found a comment /* We don't expect to see 1000+ seconds delay,
unsigned is enough */ in networking/arping.c (which probably is affected
by the problem as well). The above case introduces 1000000000+ seconds
delay :). 3600 seconds at daylight saving time change is a piece of cake.
Regards,
Adrian
--- busybox-1.19.4/networking/udhcp/arpping.c 2012-02-04 20:24:55.000000000
+0100
+++ busybox-1.19.4-arpping/networking/udhcp/arpping.c 2012-04-11
09:36:16.777579400 +0200
@@ -41,7 +41,7 @@
uint8_t *from_mac,
const char *interface)
{
- int timeout_ms;
+ signed long long timeout_ms;
struct pollfd pfd[1];
#define s (pfd[0].fd) /* socket */
int rv = 1; /* "no reply received" yet */
@@ -87,7 +87,7 @@
do {
typedef uint32_t aliased_uint32_t FIX_ALIASING;
int r;
- unsigned prevTime = monotonic_ms();
+ unsigned long long prevTime = monotonic_ms();
pfd[0].events = POLLIN;
r = safe_poll(pfd, 1, timeout_ms);
@@ -118,7 +118,7 @@
break;
}
}
- timeout_ms -= (unsigned)monotonic_ms() - prevTime;
+ timeout_ms -= monotonic_ms() - prevTime;
} while (timeout_ms > 0);
ret:
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox