Add support for using printf-escaped strings in configuration
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>
This commit is contained in:
parent
6bc1f95613
commit
5c4b93d72e
2 changed files with 29 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue