diff options
| author | Hauke Mehrtens | 2026-05-23 12:41:19 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-18 00:35:21 +0000 |
| commit | 909847c4054c22d4b27aac83d4d9234cb30e9e73 (patch) | |
| tree | 99748f89a70084571ebf5d8fb593df33746f53c3 | |
| parent | f2cfc8dd420693868c83459649e0605c79461360 (diff) | |
| download | odhcpd-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.c | 5 |
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 { |