From: Antonio Huete Jimenez Date: Tue, 14 Aug 2012 22:54:02 +0000 (+0200) Subject: dhclient - Delete trailing NUL's when parsing NVT ASCII options. X-Git-Tag: v3.2.0~319 X-Git-Url: http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/f568cd1e4b2b81c7ff0fbd231348721286d6c3ce dhclient - Delete trailing NUL's when parsing NVT ASCII options. - RFC 2132 says "Options containing NVT ASCII data SHOULD NOT include a trailing NULL; however, the receiver of such options MUST be prepared to delete trailing nulls if they exist." - Should fix odd results when 'append'ing info to such options via dhclient.conf. Taken-from: OpenBSD --- diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index 3db0db2..3022dd0 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: src/sbin/dhclient/options.c,v 1.39 2011/05/11 14:38:36 krw Exp $ */ +/* $OpenBSD: src/sbin/dhclient/options.c,v 1.40 2012/06/26 14:36:11 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -86,6 +86,19 @@ parse_option_buffer(struct option_data *options, unsigned char *buffer, warning("rejecting bogus offer."); return (0); } + + /* + * Strip trailing NULs from ascii ('t') options. They + * will be treated as DHO_PAD options. i.e. ignored. RFC 2132 + * says "Options containing NVT ASCII data SHOULD NOT include + * a trailing NULL; however, the receiver of such options + * MUST be prepared to delete trailing nulls if they exist." + */ + if (dhcp_options[code].format[0] == 't') { + for (len = s[1]; len > 0 && s[len + 1] == '\0'; len--) + ; + } + /* * If we haven't seen this option before, just make * space for it and copy it there.