[Dnsmasq-discuss] [PATCH 1/2] Do not retain rejected relay option space.
ooonea
ooonea at gmail.com
Mon Nov 16 18:57:48 UTC 2026
Clear endopt when there is no room for the relay option, so the next server cannot reuse an unchecked pointer. Compare against the last valid start without forming a pointer beyond the packet.
Assisted-by: OpenAI Codex
---
Source review: clear the cached pointer on rejection and compare against
the last valid start. The insufficient-space case was not executed.
Also verified: make -j2 and dnsmasq --test, with no build warnings.
src/rfc2131.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rfc2131.c b/src/rfc2131.c
index ec0194b..0540149 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -3148,8 +3148,11 @@ void relay_upstream4(struct in_addr iface_addr, int iface_index, struct dhcp_pac
We only need to do this once, and poke the address/interface/flags into the same place each time. */
if (!(endopt = option_find1((&mess->options[0] + sizeof(u32)), ((unsigned char *)mess) + sz, OPTION_END, 0)) ||
- (endopt + 24 > (unsigned char *)(mess + 1)))
- continue;
+ (endopt > (unsigned char *)(mess + 1) - 24))
+ {
+ endopt = NULL;
+ continue;
+ }
endopt[1] = 21; /* length */
endopt[2] = SUBOPT_SUBNET_SELECT;
More information about the Dnsmasq-discuss
mailing list