]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add support for using printf-escaped strings in configuration
authorJouni Malinen <j@w1.fi>
Tue, 7 Aug 2012 10:50:39 +0000 (13:50 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 7 Aug 2012 10:50:39 +0000 (13:50 +0300)
P"<escaped string>" can now be used as an alternative method for
specifying non-ASCII strings (including control characters). For
example, ssid=P"abc\x00test".

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/config.c
wpa_supplicant/wpa_supplicant.conf

index 0ce4d09499b095929a5485f665aad4cec5208698..94052c5fab62868635fa10dc188f6f3fd32a58eb 100644 (file)
@@ -68,6 +68,31 @@ static char * wpa_config_parse_string(const char *value, size_t *len)
                        return NULL;
                os_memcpy(str, value, *len);
                str[*len] = '\0';
+               return str;
+       } else if (*value == 'P' && value[1] == '"') {
+               const char *pos;
+               char *tstr, *str;
+               size_t tlen;
+               value += 2;
+               pos = os_strrchr(value, '"');
+               if (pos == NULL || pos[1] != '\0')
+                       return NULL;
+               tlen = pos - value;
+               tstr = os_malloc(tlen + 1);
+               if (tstr == NULL)
+                       return NULL;
+               os_memcpy(tstr, value, tlen);
+               tstr[tlen] = '\0';
+
+               str = os_malloc(tlen + 1);
+               if (str == NULL) {
+                       os_free(tstr);
+                       return NULL;
+               }
+
+               *len = printf_decode((u8 *) str, tlen + 1, tstr);
+               os_free(tstr);
+
                return str;
        } else {
                u8 *str;
index 1154aba3aed43b25b6f70b898cc968b1b86893ef..37e36b343c32478a057da64788aea843dbd4441b 100644 (file)
@@ -406,8 +406,10 @@ fast_reauth=1
 #      to external action script through wpa_cli as WPA_ID_STR environment
 #      variable to make it easier to do network specific configuration.
 #
-# ssid: SSID (mandatory); either as an ASCII string with double quotation or
-#      as hex string; network name
+# ssid: SSID (mandatory); network name in one of the optional formats:
+#      - an ASCII string with double quotation
+#      - a hex string (two characters per octet of SSID)
+#      - a printf-escaped ASCII string P"<escaped string>"
 #
 # scan_ssid:
 #      0 = do not scan this SSID with specific Probe Request frames (default)