From: Paul Donald Date: Mon, 17 Nov 2025 03:18:26 +0000 (+0100) Subject: dhcpv6: fix processing PIO exclusion loop variable collision X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=af9968c0293fd2ca81edfc29575decb006cd73fc;p=project%2Fodhcp6c.git dhcpv6: fix processing PIO exclusion loop variable collision An inner loop variable i potentially collides with the outer loop i, possibly giving unexpected results. Commit b146f9adc80c introduced both the inner and outer loop. Fixes: b146f9adc80c ("add support for multiple prefixes with distinct IAIDs") Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcp6c/pull/124 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 872f169..68c04f4 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -816,8 +816,9 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs) excl >>= (64 - e[j].priority); excl <<= 8 - ((e[j].priority - e[j].length) % 8); - for (size_t i = ex_len - 5; i > 0; --i, excl >>= 8) - ia_pd[ia_pd_len + i] = excl & 0xff; + for (size_t k = ex_len - 5; k > 0; --k, excl >>= 8) + ia_pd[ia_pd_len + k] = excl & 0xff; + ia_pd_len += ex_len - 5; }