dhcpv6: fix processing PIO exclusion loop variable collision
authorPaul Donald <[email protected]>
Mon, 17 Nov 2025 03:18:26 +0000 (04:18 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Tue, 18 Nov 2025 07:18:57 +0000 (08:18 +0100)
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 <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/124
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv6.c

index 872f169e67453c78fc2b4898df58b1c50d9ee07b..68c04f40522088ffa3364d8acbeba29e5f0b5d69 100644 (file)
@@ -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;
                                }