From e28e822091c4ea9e164b7bb15b6c884c66593f8e Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Fri, 13 Sep 2019 12:42:17 +0100 Subject: [PATCH] DHCP: Check we have enough for data for IP header as well. This is totally my bad - Maciej's patch had this length check in but somehow my patch import lost it. --- src/dhcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dhcp.c b/src/dhcp.c index 3d8e46bd..1fb2f4a1 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -3264,7 +3264,13 @@ valid_udp_packet(void *packet, size_t plen, struct in_addr *from, if (from != NULL) from->s_addr = ip->ip_src.s_addr; + /* Check we have the IP header */ ip_hlen = (size_t)ip->ip_hl * 4; + if (ip_hlen > plen) { + errno = ENOBUFS; + return -1; + } + if (in_cksum(ip, ip_hlen, NULL) != 0) { errno = EINVAL; return -1; -- 2.47.2