From owner-svn-src-all@FreeBSD.ORG Fri Dec 30 14:33:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E24EB1065675; Fri, 30 Dec 2011 14:33:08 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2A1C8FC16; Fri, 30 Dec 2011 14:33:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBUEX8eb017345; Fri, 30 Dec 2011 14:33:08 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBUEX8GX017343; Fri, 30 Dec 2011 14:33:08 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201112301433.pBUEX8GX017343@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Fri, 30 Dec 2011 14:33:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229000 - head/sbin/dhclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2011 14:33:09 -0000 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 (earlier version) Reviewed by: Fabian Keil 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