From owner-svn-src-all@freebsd.org Fri May 6 05:44:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DFAA9B30562; Fri, 6 May 2016 05:44:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F6891866; Fri, 6 May 2016 05:44:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u465iCdE025941; Fri, 6 May 2016 05:44:12 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u465iCNk025940; Fri, 6 May 2016 05:44:12 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201605060544.u465iCNk025940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 6 May 2016 05:44:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r299156 - stable/10/sbin/dhclient X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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, 06 May 2016 05:44:14 -0000 Author: sephe Date: Fri May 6 05:44:12 2016 New Revision: 299156 URL: https://svnweb.freebsd.org/changeset/base/299156 Log: MFC r298385 dhclient: Log a warning instead of bailing upon "illegal" options In Azure, the DHCP servers add private option (id 0xf5), which contains binary form of an IPv4 address. Once this option is converted to string form, it could contain '$', e.g. IPv4 address: 100.72.36.54 binary form: 0x64 0x48 0x24 0x36 string form: "dH$6" dhclient bails upon "illegal" options like the above example, thus the VM bring-up will fail. Also as a side note, this "illegal" option detection was added in OpenBSD ~11years ago: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.50&content-type=text/x-cvsweb-markup And it was removed along with the removal of script support in OpenBSD ~3years ago: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sbin/dhclient/dhclient.c?rev=1.159&content-type=text/x-cvsweb-markup Reported by: Hongxiong Xian Reviewed by: jhb, Dexuan Cui Tested by: Hongxiong Xian Analyzed by: Dong Liu Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5853 Modified: stable/10/sbin/dhclient/dhclient.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dhclient/dhclient.c ============================================================================== --- stable/10/sbin/dhclient/dhclient.c Fri May 6 05:24:10 2016 (r299155) +++ stable/10/sbin/dhclient/dhclient.c Fri May 6 05:44:12 2016 (r299156) @@ -2277,6 +2277,17 @@ script_set_env(struct client_state *clie { int i, j, namelen; + /* No `` or $() command substitution allowed in environment values! */ + for (j=0; j < strlen(value); j++) + switch (value[j]) { + case '`': + case '$': + warning("illegal character (%c) in value '%s'", + value[j], value); + /* Ignore this option */ + return; + } + namelen = strlen(name); for (i = 0; client->scriptEnv[i]; i++) @@ -2313,16 +2324,6 @@ script_set_env(struct client_state *clie strlen(value) + 1); if (client->scriptEnv[i] == NULL) error("script_set_env: no memory for variable assignment"); - - /* No `` or $() command substitution allowed in environment values! */ - for (j=0; j < strlen(value); j++) - switch (value[j]) { - case '`': - case '$': - error("illegal character (%c) in value '%s'", value[j], - value); - /* not reached */ - } snprintf(client->scriptEnv[i], strlen(prefix) + strlen(name) + 1 + strlen(value) + 1, "%s%s=%s", prefix, name, value); }