Date: Fri, 30 Dec 2011 14:33:08 +0000 (UTC) From: Jean-Sebastien Pedron <dumbbell@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r229000 - head/sbin/dhclient Message-ID: <201112301433.pBUEX8GX017343@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dumbbell Date: Fri Dec 30 14:33:08 2011 New Revision: 229000 URL: http://svn.freebsd.org/changeset/base/229000 Log: Invalid Domain Search option isn't considered as a fatal error In the original Domain Search option patch, an invalid option value would cause the whole lease to be rejected. However, DHCP servers who emit such an invalid value are more common than I thought. With this new patch, just the option is rejected, not the entire lease. PR: bin/163431 Submitted by: Fabian Keil <fk@fabiankeil.de> (earlier version) Reviewed by: Fabian Keil <fk@fabiankeil.de> Sponsored by: Yakaz (http://www.yakaz.com) Modified: head/sbin/dhclient/options.c Modified: head/sbin/dhclient/options.c ============================================================================== --- head/sbin/dhclient/options.c Fri Dec 30 14:30:16 2011 (r228999) +++ head/sbin/dhclient/options.c Fri Dec 30 14:33:08 2011 (r229000) @@ -211,7 +211,7 @@ parse_option_buffer(struct packet *packe void expand_domain_search(struct packet *packet) { - int offset, expanded_len; + int offset, expanded_len, next_domain_len; struct option_data *option; unsigned char *domain_search, *cursor; @@ -224,9 +224,13 @@ expand_domain_search(struct packet *pack expanded_len = 0; offset = 0; while (offset < option->len) { + next_domain_len = find_search_domain_name_len(option, &offset); + if (next_domain_len < 0) + /* The Domain Search option value is invalid. */ + return; + /* We add 1 for the space between domain names. */ - expanded_len += - find_search_domain_name_len(option, &offset) + 1; + expanded_len += next_domain_len + 1; } if (expanded_len > 0) /* Remove 1 for the superfluous trailing space. */ @@ -271,8 +275,9 @@ find_search_domain_name_len(struct optio /* This is a pointer to another list of labels. */ if (i + 1 >= option->len) { /* The pointer is truncated. */ - error("Truncated pointer in DHCP Domain " + warning("Truncated pointer in DHCP Domain " "Search option."); + return (-1); } pointer = ((label_len & ~(0xC0)) << 8) + @@ -282,8 +287,9 @@ find_search_domain_name_len(struct optio * The pointer must indicates a prior * occurance. */ - error("Invalid forward pointer in DHCP Domain " - "Search option compression."); + warning("Invalid forward pointer in DHCP " + "Domain Search option compression."); + return (-1); } pointed_len = find_search_domain_name_len(option, @@ -295,7 +301,9 @@ find_search_domain_name_len(struct optio } if (i + label_len >= option->len) { - error("Truncated label in DHCP Domain Search option."); + warning("Truncated label in DHCP Domain Search " + "option."); + return (-1); } /* @@ -308,9 +316,9 @@ find_search_domain_name_len(struct optio i += label_len + 1; } - error("Truncated DHCP Domain Search option."); + warning("Truncated DHCP Domain Search option."); - return (0); + return (-1); } void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112301433.pBUEX8GX017343>