From 007ae1a6ae8092878adccde1f610ea9dd86e5aad Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Wed, 3 Jul 2013 19:15:36 +0200 Subject: [PATCH] Add better overflow safety in resend --- src/dhcpv6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index ed6b8f8..64c0cb4 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -350,14 +350,14 @@ static int64_t dhcpv6_rand_delay(int64_t time) { int random; odhcp6c_random(&random, sizeof(random)); - return (time * (random % 1000)) / 10000; + return (time * ((int64_t)random % 1000LL)) / 10000LL; } int dhcpv6_request(enum dhcpv6_msg type) { uint8_t buf[1536]; - uint32_t timeout = UINT32_MAX; + uint64_t timeout = UINT32_MAX; struct dhcpv6_retx *retx = &dhcpv6_retx[type]; if (retx->delay) { @@ -378,7 +378,7 @@ int dhcpv6_request(enum dhcpv6_msg type) if (timeout == 0) return -1; - syslog(LOG_NOTICE, "Sending %s (timeout %us)", retx->name, timeout); + syslog(LOG_NOTICE, "Sending %s (timeout %us)", retx->name, (unsigned)timeout); uint64_t start = odhcp6c_get_milli_time(), round_start = start, elapsed; -- 2.25.1