hostapd: Validate the country_code parameter value

cfg80211/regulatory supports only ISO 3166-1 alpha2 country code and
that's what this parameter is supposed to use, so validate the country
code input before accepting the value. Only characters A..Z are
accepted.

Signed-off-by: Sriram R <srirrama@codeaurora.org>
This commit is contained in:
Sriram R 2020-03-26 08:42:19 +05:30 committed by Jouni Malinen
parent d4f5d1f0c7
commit e149051ced

View file

@ -2463,6 +2463,13 @@ static int hostapd_config_fill(struct hostapd_config *conf,
} else if (os_strcmp(buf, "skip_inactivity_poll") == 0) { } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
bss->skip_inactivity_poll = atoi(pos); bss->skip_inactivity_poll = atoi(pos);
} else if (os_strcmp(buf, "country_code") == 0) { } else if (os_strcmp(buf, "country_code") == 0) {
if (pos[0] < 'A' || pos[0] > 'Z' ||
pos[1] < 'A' || pos[1] > 'Z') {
wpa_printf(MSG_ERROR,
"Line %d: Invalid country_code '%s'",
line, pos);
return 1;
}
os_memcpy(conf->country, pos, 2); os_memcpy(conf->country, pos, 2);
} else if (os_strcmp(buf, "country3") == 0) { } else if (os_strcmp(buf, "country3") == 0) {
conf->country[2] = strtol(pos, NULL, 16); conf->country[2] = strtol(pos, NULL, 16);