t.tv_sec is a 32 bit integer and it is multiplied by 1000 which makes
it overflow every ~50 days. The multiplication is done in 32 bit mode
and not in 64 bit, because both values are 32 bit. This patch makes the
constant number 64 bit and now a 64 bit multiplication is done which
does not overflow. This probably caused my odhcp6 client to send a
broadcast storm on the wan interface, which happened after running
OpenWrt AA for 50 days.

This patch was only compile tested by me.

Signed-off-by: Hauke Mehrtens <ha...@hauke-m.de>
---
 src/odhcp6c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/odhcp6c.c b/src/odhcp6c.c
index 3c6b3b0..4dc643d 100644
--- a/src/odhcp6c.c
+++ b/src/odhcp6c.c
@@ -470,7 +470,7 @@ uint64_t odhcp6c_get_milli_time(void)
 {
        struct timespec t = {0, 0};
        syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t);
-       return t.tv_sec * 1000 + t.tv_nsec / 1000000;
+       return t.tv_sec * 1000LL + t.tv_nsec / 1000000LL;
 }
 
 
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to