diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 9692251f6..0279cd7f3 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -1289,45 +1289,52 @@ static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos, } -static int parse_venue_name(struct hostapd_bss_config *bss, char *pos, - int line) +static int parse_lang_string(struct hostapd_lang_string **array, + unsigned int *count, char *pos) { char *sep; size_t clen, nlen; - struct hostapd_venue_name *vn; + struct hostapd_lang_string *ls; sep = os_strchr(pos, ':'); if (sep == NULL) - goto fail; + return -1; *sep++ = '\0'; clen = os_strlen(pos); if (clen < 2) - goto fail; + return -1; nlen = os_strlen(sep); if (nlen > 252) - goto fail; - - vn = os_realloc_array(bss->venue_name, bss->venue_name_count + 1, - sizeof(struct hostapd_venue_name)); - if (vn == NULL) return -1; - bss->venue_name = vn; - vn = &bss->venue_name[bss->venue_name_count]; - bss->venue_name_count++; + ls = os_realloc_array(*array, *count + 1, + sizeof(struct hostapd_lang_string)); + if (ls == NULL) + return -1; - os_memset(vn->lang, 0, sizeof(vn->lang)); - os_memcpy(vn->lang, pos, clen); - vn->name_len = nlen; - os_memcpy(vn->name, sep, nlen); + *array = ls; + ls = &(*array)[*count]; + (*count)++; + + os_memset(ls->lang, 0, sizeof(ls->lang)); + os_memcpy(ls->lang, pos, clen); + ls->name_len = nlen; + os_memcpy(ls->name, sep, nlen); return 0; +} -fail: - wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'", - line, pos); - return -1; + +static int parse_venue_name(struct hostapd_bss_config *bss, char *pos, + int line) +{ + if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'", + line, pos); + return -1; + } + return 0; } diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 5dfc8a615..0077a98b3 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -145,7 +145,7 @@ struct hostapd_roaming_consortium { u8 oi[MAX_ROAMING_CONSORTIUM_LEN]; }; -struct hostapd_venue_name { +struct hostapd_lang_string { u8 lang[3]; u8 name_len; u8 name[252]; @@ -386,7 +386,7 @@ struct hostapd_bss_config { /* IEEE 802.11u - Venue Name duples */ unsigned int venue_name_count; - struct hostapd_venue_name *venue_name; + struct hostapd_lang_string *venue_name; /* IEEE 802.11u - Network Authentication Type */ u8 *network_auth_type; diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c index 5572c073f..3951a0772 100644 --- a/src/ap/gas_serv.c +++ b/src/ap/gas_serv.c @@ -182,7 +182,7 @@ static void anqp_add_venue_name(struct hostapd_data *hapd, struct wpabuf *buf) wpabuf_put_u8(buf, hapd->conf->venue_group); wpabuf_put_u8(buf, hapd->conf->venue_type); for (i = 0; i < hapd->conf->venue_name_count; i++) { - struct hostapd_venue_name *vn; + struct hostapd_lang_string *vn; vn = &hapd->conf->venue_name[i]; wpabuf_put_u8(buf, 3 + vn->name_len); wpabuf_put_data(buf, vn->lang, 3);