summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-05-23 12:41:19 +0000
committerHauke Mehrtens2026-06-18 00:35:21 +0000
commit909847c4054c22d4b27aac83d4d9234cb30e9e73 (patch)
tree99748f89a70084571ebf5d8fb593df33746f53c3
parentf2cfc8dd420693868c83459649e0605c79461360 (diff)
downloadodhcpd-909847c4054c22d4b27aac83d4d9234cb30e9e73.tar.gz
dhcpv6-pxe: free previous default entry on replacement
ipv6_pxe_entry_new() stores arch == 0xFFFFFFFF (the "no-arch / default" case) in the standalone ipv6_pxe_default pointer instead of on the list. When the function is called with that arch more than once between ipv6_pxe_clear() runs — e.g. a UCI config with two boot6 sections that omit the arch field — the previous default was simply overwritten and leaked. Free the prior default before replacing it. Assisted-by: Claude:claude-opus-4-7 Link: https://github.com/openwrt/odhcpd/pull/401 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> (cherry picked from commit 3e1dd3b16c9a9f83a85bc1a889ac636f2528d043)
-rw-r--r--src/dhcpv6-pxe.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dhcpv6-pxe.c b/src/dhcpv6-pxe.c
index 58d8466..4f15f00 100644
--- a/src/dhcpv6-pxe.c
+++ b/src/dhcpv6-pxe.c
@@ -32,6 +32,11 @@ const struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url)
ipe->bootfile_url.type = htons(DHCPV6_OPT_BOOTFILE_URL);
if (arch == 0xFFFFFFFF) {
+ /* The "default" entry lives outside ipv6_pxe_list; if config
+ * already supplied one (e.g. two boot6 sections without an
+ * arch), free the previous one before replacing it, otherwise
+ * it would leak until ipv6_pxe_clear() runs. */
+ free(ipv6_pxe_default);
ipv6_pxe_default = ipe;
}
else {