HS 2.0: Allow printf format parsing with language:name strings

This allows Hotspot 2.0 and Interworking strings that use language:name
string (e.g., venue_name) to be encoded using printf format to enter
special characters like newline.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Kyeyoon Park 2013-09-25 13:03:16 +03:00 committed by Jouni Malinen
parent 913c19c6e5
commit f224cf05ab
2 changed files with 21 additions and 7 deletions

View file

@ -1289,26 +1289,34 @@ static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
static int parse_lang_string(struct hostapd_lang_string **array, static int parse_lang_string(struct hostapd_lang_string **array,
unsigned int *count, char *pos) unsigned int *count, char *pos)
{ {
char *sep; char *sep, *str = NULL;
size_t clen, nlen; size_t clen, nlen, slen;
struct hostapd_lang_string *ls; struct hostapd_lang_string *ls;
int ret = -1;
if (*pos == '"' || (*pos == 'P' && pos[1] == '"')) {
str = wpa_config_parse_string(pos, &slen);
if (!str)
return -1;
pos = str;
}
sep = os_strchr(pos, ':'); sep = os_strchr(pos, ':');
if (sep == NULL) if (sep == NULL)
return -1; goto fail;
*sep++ = '\0'; *sep++ = '\0';
clen = os_strlen(pos); clen = os_strlen(pos);
if (clen < 2 || clen > sizeof(ls->lang)) if (clen < 2 || clen > sizeof(ls->lang))
return -1; goto fail;
nlen = os_strlen(sep); nlen = os_strlen(sep);
if (nlen > 252) if (nlen > 252)
return -1; goto fail;
ls = os_realloc_array(*array, *count + 1, ls = os_realloc_array(*array, *count + 1,
sizeof(struct hostapd_lang_string)); sizeof(struct hostapd_lang_string));
if (ls == NULL) if (ls == NULL)
return -1; goto fail;
*array = ls; *array = ls;
ls = &(*array)[*count]; ls = &(*array)[*count];
@ -1319,7 +1327,10 @@ static int parse_lang_string(struct hostapd_lang_string **array,
ls->name_len = nlen; ls->name_len = nlen;
os_memcpy(ls->name, sep, nlen); os_memcpy(ls->name, sep, nlen);
return 0; ret = 0;
fail:
os_free(str);
return ret;
} }

View file

@ -1457,6 +1457,9 @@ own_ip_addr=127.0.0.1
# information to be complete. # information to be complete.
#venue_name=eng:Example venue #venue_name=eng:Example venue
#venue_name=fin:Esimerkkipaikka #venue_name=fin:Esimerkkipaikka
# Alternative format for language:value strings:
# (double quoted string, printf-escaped string)
#venue_name=P"eng:Example\nvenue"
# Network Authentication Type # Network Authentication Type
# This parameter indicates what type of network authentication is used in the # This parameter indicates what type of network authentication is used in the