aboutsummaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorSepherosa Ziehau <sephe@FreeBSD.org>2016-04-20 23:56:25 +0000
committerSepherosa Ziehau <sephe@FreeBSD.org>2016-04-20 23:56:25 +0000
commitdd09ce39306e8b4856eb82bf2de8a59fdd7ff667 (patch)
tree5193b5c5773f1e2179336344dcf3a32a20f48f31 /sbin/dhclient/dhclient.c
parent1782ba0c1f62936233424e2719701a2c5fc6d05c (diff)
downloadsrc-dd09ce39306e8b4856eb82bf2de8a59fdd7ff667.tar.gz
src-dd09ce39306e8b4856eb82bf2de8a59fdd7ff667.zip
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 <v-hoxian microsoft com> Reviewed by: jhb, Dexuan Cui <decui microsoft com> Tested by: Hongxiong Xian <v-hoxian microsoft com> Analyzed by: Dong Liu <doliu microsoft com> MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5853
Notes
Notes: svn path=/head/; revision=298385
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 79058133f7b2..4444f29e5d83 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -2275,6 +2275,17 @@ script_set_env(struct client_state *client, const char *prefix,
{
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++)
@@ -2311,16 +2322,6 @@ script_set_env(struct client_state *client, const char *prefix,
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);
}