changeset 2943:8fd60c6f6672 draft

Disallow / in the SSID when using in a lease filename.
author Roy Marples <roy@marples.name>
date Mon, 09 Feb 2015 17:32:34 +0000
parents e4ebe44debc7
children 466084782756
files dhcp-common.c dhcp-common.h
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp-common.c	Mon Feb 09 15:35:49 2015 +0000
+++ b/dhcp-common.c	Mon Feb 09 17:32:34 2015 +0000
@@ -456,14 +456,15 @@
 			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 @@
 	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';
--- a/dhcp-common.h	Mon Feb 09 15:35:49 2015 +0000
+++ b/dhcp-common.h	Mon Feb 09 17:32:34 2015 +0000
@@ -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 */