From: Roy Marples Date: Sun, 12 Apr 2009 19:16:57 +0000 (+0000) Subject: We should ignore DHCP messages without a ServerID, #166. X-Git-Tag: v5.0.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=572ccfb7e23b6aec55b820433c75e90127c2a006;p=thirdparty%2Fdhcpcd.git We should ignore DHCP messages without a ServerID, #166. --- diff --git a/dhcpcd.c b/dhcpcd.c index f32e0459..82831873 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -456,6 +456,12 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp) /* We may have found a BOOTP server */ if (get_option_uint8(&type, dhcp, DHO_MESSAGETYPE) == -1) type = 0; + else if (get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == -1) { + /* We should ignore invalid NAK messages without a ServerID */ + syslog(LOG_WARNING, "%s: ignoring DHCP message; no Server ID", + iface->name); + return; + } /* We should restart on a NAK */ if (type == DHCP_NAK) { @@ -494,9 +500,8 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp) lease->frominfo = 0; lease->addr.s_addr = dhcp->yiaddr; lease->server.s_addr = 0; - if (type) - get_option_addr(&lease->server.s_addr, dhcp, - DHO_SERVERID); + if (type != 0) + lease->server.s_addr = addr.s_addr; log_dhcp(LOG_INFO, "offered", iface, dhcp); free(state->offer); state->offer = dhcp;