From 1f4d57d608ac62bead410e282d4e14d4085b5e6a Mon Sep 17 00:00:00 2001 From: Martine Lenders <m.lenders@fu-berlin.de> Date: Mon, 12 Nov 2018 14:32:41 +0100 Subject: [PATCH] gnrc_ipv6_nib/arsm: ensure proper int width in backoff calculation Otherwise, the result might flow over on 8/16-bit platforms --- sys/net/gnrc/network_layer/ipv6/nib/_nib-arsm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-arsm.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-arsm.c index 99f69f4e99..e14a6fd030 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-arsm.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-arsm.c @@ -519,7 +519,8 @@ static inline uint32_t _exp_backoff_retrans_timer(uint8_t ns_sent, /* backoff according to https://tools.ietf.org/html/rfc7048 with * BACKOFF_MULTIPLE == 2 */ - tmp = ((1 << ns_sent) * retrans_timer * tmp) / US_PER_MS; + tmp = (uint32_t)(((uint64_t)(((uint32_t) 1) << ns_sent) * retrans_timer * + tmp) / US_PER_MS); /* random factors were statically multiplied with 1000 ^ */ if (tmp > NDP_MAX_RETRANS_TIMER_MS) { tmp = NDP_MAX_RETRANS_TIMER_MS; -- GitLab