]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Disallow / in the SSID when using in a lease filename.
authorRoy Marples <roy@marples.name>
Mon, 9 Feb 2015 17:32:34 +0000 (17:32 +0000)
committerRoy Marples <roy@marples.name>
Mon, 9 Feb 2015 17:32:34 +0000 (17:32 +0000)
dhcp-common.c
dhcp-common.h

index 1b87b720d2a0385c71b4a9d5374eabd2556986dd..8b798e86fef7bee60699e04c86e4e815f849ceaf 100644 (file)
@@ -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';
index e4c89f502443b189a19e3115ddedf88fa37977e8..43666c4b89d5dc87b76246cbd796ac49c5df44d6 100644 (file)
@@ -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 */