From 5c4b93d72ecf6d1d5b21a60b3e78db3948d0f034 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 7 Aug 2012 13:50:39 +0300 Subject: [PATCH] Add support for using printf-escaped strings in configuration P"" 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 --- wpa_supplicant/config.c | 25 +++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant.conf | 6 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 0ce4d0949..94052c5fa 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -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; diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 1154aba3a..37e36b343 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -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"" # # scan_ssid: # 0 = do not scan this SSID with specific Probe Request frames (default)