From c4b4938a599aeaa4e454e94e32ab5d25f881d763 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Thu, 1 Sep 2011 23:05:56 -0400 Subject: [PATCH] Validate that server reply has the client hardware address field set to be equal to our MAC address. Win7 verifies this field, so it should be safe enough to check it, too. --- ndhc/dhcp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ndhc/dhcp.c b/ndhc/dhcp.c index 1cf78d4..3b2ee27 100644 --- a/ndhc/dhcp.c +++ b/ndhc/dhcp.c @@ -503,6 +503,15 @@ static int validate_dhcp_packet(struct client_state_t *cs, int len, packet->xid, cs->xid); return 0; } + if (memcmp(packet->chaddr, client_config.arp, sizeof client_config.arp)) { + log_line("Packet client MAC %.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx does not equal our MAC %.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx. Ignoring it.", + packet->chaddr[0], packet->chaddr[1], packet->chaddr[2], + packet->chaddr[3], packet->chaddr[4], packet->chaddr[5], + client_config.arp[0], client_config.arp[1], + client_config.arp[2], client_config.arp[3], + client_config.arp[4], client_config.arp[5]); + return 0; + } *msgtype = get_option_msgtype(packet); if (!*msgtype) { log_line("Packet does not specify a DHCP message type. Ignoring.");