summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2012-06-26 14:36:11 +0000
committerkrw <krw@openbsd.org>2012-06-26 14:36:11 +0000
commitdf453039eae19e9c7383e92106277de59b3db790 (patch)
tree1cccd18c1e36e3bb60abea27f5a08364c63120b1
parentinitialize 'reason' variable before passing it to the pflog_packet; (diff)
downloadwireguard-openbsd-df453039eae19e9c7383e92106277de59b3db790.tar.xz
wireguard-openbsd-df453039eae19e9c7383e92106277de59b3db790.zip
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." So delete (all) trailing NUL's when parsing NVT ASCII options. Should fix odd results when 'append'ing info to such options via dhclient.conf. FreeBSD commit to fix 'append' logic in a different way pointed out by brad.
-rw-r--r--sbin/dhclient/options.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index 052aa8975de..ac816f5d452 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.39 2011/05/11 14:38:36 krw Exp $ */
+/* $OpenBSD: 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.