From: Roy Marples Date: Mon, 9 Feb 2015 17:32:34 +0000 (+0000) Subject: Disallow / in the SSID when using in a lease filename. X-Git-Tag: v6.8.0~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=937bc321f1a48ea10f2f10706938a0d3f57a928c;p=thirdparty%2Fdhcpcd.git Disallow / in the SSID when using in a lease filename. --- diff --git a/dhcp-common.c b/dhcp-common.c index 1b87b720..8b798e86 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -456,14 +456,15 @@ print_string(char *dst, size_t len, int type, const uint8_t *data, size_t dl) errno = EINVAL; break; } - if (!(type & (ASCII | RAW | ESCSTRING)) /*plain string */ && + if (!(type & (ASCII | RAW | ESCSTRING | ESCFILE)) /* plain */ && (!isascii(c) && !isprint(c))) { errno = EINVAL; break; } - if (type & ESCSTRING && - (c == '\\' || !isascii(c) || !isprint(c))) + if ((type & (ESCSTRING | ESCFILE) && + (c == '\\' || !isascii(c) || !isprint(c))) || + (type & ESCFILE && (c == '/'))) { errno = EINVAL; if (c == '\\') { @@ -748,7 +749,7 @@ dhcp_set_leasefile(char *leasefile, size_t len, int family, if (ifp->wireless) { ssid[0] = '-'; print_string(ssid + 1, sizeof(ssid) - 1, - ESCSTRING, + ESCFILE, (const uint8_t *)ifp->ssid, ifp->ssid_len); } else ssid[0] = '\0'; diff --git a/dhcp-common.h b/dhcp-common.h index e4c89f50..43666c4b 100644 --- a/dhcp-common.h +++ b/dhcp-common.h @@ -65,6 +65,7 @@ #define ASCII (1 << 22) #define RAW (1 << 23) #define ESCSTRING (1 << 24) +#define ESCFILE (1 << 25) struct dhcp_opt { uint32_t option; /* Also used for IANA Enterpise Number */