From acccb9aa8388b62964738eb1b0ac9d3d38f180e6 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Thu, 28 Jul 2005 00:24:39 +0000 Subject: [PATCH] Don't reject packets with server names containing characters that are not allowed in domain names. RFC 2132 does not list valid or invalid characters and the ISC client accepts anything here. Reported by: ps --- sbin/dhclient/dhclient.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 6007f32fb161..9f2b2690b34a 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -987,7 +987,12 @@ packet_to_lease(struct packet *packet) lease->address.len = sizeof(packet->raw->yiaddr); memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len); - /* If the server name was filled out, copy it. */ + /* If the server name was filled out, copy it. + Do not attempt to validate the server name as a host name. + RFC 2131 merely states that sname is NUL-terminated (which do + do not assume) and that it is the server's host name. Since + the ISC client and server allow arbitrary characters, we do + as well. */ if ((!packet->options[DHO_DHCP_OPTION_OVERLOAD].len || !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2)) && packet->raw->sname[0]) { @@ -999,12 +1004,6 @@ packet_to_lease(struct packet *packet) } memcpy(lease->server_name, packet->raw->sname, DHCP_SNAME_LEN); lease->server_name[DHCP_SNAME_LEN]='\0'; - if (!res_hnok(lease->server_name) ) { - warning("Bogus server name %s", lease->server_name ); - free_client_lease(lease); - return (NULL); - } - } /* Ditto for the filename. */