aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2017-02-05 14:31:03 (GMT)
committerJouni Malinen <j@w1.fi>2017-02-05 14:31:03 (GMT)
commit1fb4437c802d3dea1fba895860c90cf1b6cd660a (patch)
tree57e951163e8cb586a779214fea6e0aa2af742c23 /wpa_supplicant/ctrl_iface.c
parent275cc942800eb22bd7a5a413ff016594ff404ef0 (diff)
downloadhostap-1fb4437c802d3dea1fba895860c90cf1b6cd660a.zip
hostap-1fb4437c802d3dea1fba895860c90cf1b6cd660a.tar.gz
hostap-1fb4437c802d3dea1fba895860c90cf1b6cd660a.tar.bz2
tests: Validate hwaddr/hexstr input to DRIVER_EVENT SCAN_RES
To be more consistent with existing hwaddr_aton() and hexstr2bin() callers, check the return values in this test command. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/ctrl_iface.c')
-rw-r--r--wpa_supplicant/ctrl_iface.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index dff53ad..e83df72 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -8045,6 +8045,7 @@ static int wpas_ctrl_iface_driver_scan_res(struct wpa_supplicant *wpa_s,
struct wpa_scan_res *res;
struct os_reltime now;
char *pos, *end;
+ int ret = -1;
if (!param)
return -1;
@@ -8072,8 +8073,8 @@ static int wpas_ctrl_iface_driver_scan_res(struct wpa_supplicant *wpa_s,
res->flags = strtol(pos + 7, NULL, 16);
pos = os_strstr(param, " bssid=");
- if (pos)
- hwaddr_aton(pos + 7, res->bssid);
+ if (pos && hwaddr_aton(pos + 7, res->bssid))
+ goto fail;
pos = os_strstr(param, " freq=");
if (pos)
@@ -8120,8 +8121,8 @@ static int wpas_ctrl_iface_driver_scan_res(struct wpa_supplicant *wpa_s,
res->parent_tsf = strtoll(pos + 7, NULL, 16);
pos = os_strstr(param, " tsf_bssid=");
- if (pos)
- hwaddr_aton(pos + 11, res->tsf_bssid);
+ if (pos && hwaddr_aton(pos + 11, res->tsf_bssid))
+ goto fail;
pos = os_strstr(param, " ie=");
if (pos) {
@@ -8130,7 +8131,8 @@ static int wpas_ctrl_iface_driver_scan_res(struct wpa_supplicant *wpa_s,
if (!end)
end = pos + os_strlen(pos);
res->ie_len = (end - pos) / 2;
- hexstr2bin(pos, (u8 *) (res + 1), res->ie_len);
+ if (hexstr2bin(pos, (u8 *) (res + 1), res->ie_len))
+ goto fail;
}
pos = os_strstr(param, " beacon_ie=");
@@ -8140,15 +8142,18 @@ static int wpas_ctrl_iface_driver_scan_res(struct wpa_supplicant *wpa_s,
if (!end)
end = pos + os_strlen(pos);
res->beacon_ie_len = (end - pos) / 2;
- hexstr2bin(pos, ((u8 *) (res + 1)) + res->ie_len,
- res->beacon_ie_len);
+ if (hexstr2bin(pos, ((u8 *) (res + 1)) + res->ie_len,
+ res->beacon_ie_len))
+ goto fail;
}
os_get_reltime(&now);
wpa_bss_update_scan_res(wpa_s, res, &now);
+ ret = 0;
+fail:
os_free(res);
- return 0;
+ return ret;
}