From 5a9d5049381a1bcebd527838362ff4d37de6758e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 31 Jan 2017 14:43:56 +0200 Subject: [PATCH] ProxyARP: Use more robust DHCP option parsing Do not depend on undefined behavior with pointer arithmetic when checking whether there is sufficient room for an option. Signed-off-by: Jouni Malinen --- src/ap/dhcp_snoop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ap/dhcp_snoop.c b/src/ap/dhcp_snoop.c index 1b356a2b8..b9a36d760 100644 --- a/src/ap/dhcp_snoop.c +++ b/src/ap/dhcp_snoop.c @@ -62,6 +62,8 @@ static void handle_dhcp(void *ctx, const u8 *src_addr, const u8 *buf, if (*opt == DHCP_OPT_PAD) continue; + if (pos >= end || 1 + *pos > end - pos) + break; pos += *pos + 1; if (pos >= end) break;