]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Validate the IP address offered, as some faulty DHCP servers like to
authorRoy Marples <roy@marples.name>
Thu, 24 Mar 2011 01:55:06 +0000 (01:55 +0000)
committerRoy Marples <roy@marples.name>
Thu, 24 Mar 2011 01:55:06 +0000 (01:55 +0000)
give is an invalid one.

dhcpcd.c

index a3672020a31521b7cfd4024a9d295806f9836fe1..ade5e62b369d1a9d4e9c48fa17dd7e07980f79a1 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -528,7 +528,17 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp, const struct i
                        log_dhcp(LOG_WARNING, "reject DHCP", iface, dhcp, from);
                        return;
                }
-       }               
+       }
+
+       /* Ensure that the address offered is valid */
+       if ((type == 0 || type == DHCP_OFFER || type == DHCP_ACK) &&
+           (dhcp->ciaddr == INADDR_ANY || dhcp->ciaddr == INADDR_BROADCAST) &&
+           (dhcp->yiaddr == INADDR_ANY || dhcp->yiaddr == INADDR_BROADCAST))
+       {
+               log_dhcp(LOG_WARNING, "reject invalid address",
+                   iface, dhcp, from);
+               return;
+       }
 
        /* No NAK, so reset the backoff */
        state->nakoff = 1;