]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Check we have enough for data for IP header as well.
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Fri, 13 Sep 2019 11:42:17 +0000 (12:42 +0100)
committerRoy Marples <roy@marples.name>
Fri, 13 Sep 2019 11:42:17 +0000 (12:42 +0100)
This is totally my bad - Maciej's patch had this length check in
but somehow my patch import lost it.

src/dhcp.c

index 3d8e46bdebc95710a7c77109c79dac80f00f0243..1fb2f4a10fcd848cb4b0d44ec7178f2f6d095d76 100644 (file)
@@ -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;