hostapd: Check driver parameter before replacing previous value

This leaves the previously configured value in place if "SET driver ..."
command fails.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-12-27 11:33:35 +02:00
parent eb89361bde
commit 8628555f9b

View file

@ -2055,20 +2055,21 @@ static int hostapd_config_fill(struct hostapd_config *conf,
os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge)); os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge));
} else if (os_strcmp(buf, "driver") == 0) { } else if (os_strcmp(buf, "driver") == 0) {
int j; int j;
/* clear to get error below if setting is invalid */ const struct wpa_driver_ops *driver = NULL;
conf->driver = NULL;
for (j = 0; wpa_drivers[j]; j++) { for (j = 0; wpa_drivers[j]; j++) {
if (os_strcmp(pos, wpa_drivers[j]->name) == 0) { if (os_strcmp(pos, wpa_drivers[j]->name) == 0) {
conf->driver = wpa_drivers[j]; driver = wpa_drivers[j];
break; break;
} }
} }
if (conf->driver == NULL) { if (!driver) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"Line %d: invalid/unknown driver '%s'", "Line %d: invalid/unknown driver '%s'",
line, pos); line, pos);
return 1; return 1;
} }
conf->driver = driver;
} else if (os_strcmp(buf, "driver_params") == 0) { } else if (os_strcmp(buf, "driver_params") == 0) {
os_free(conf->driver_params); os_free(conf->driver_params);
conf->driver_params = os_strdup(pos); conf->driver_params = os_strdup(pos);