From 376900708a7c1e4637f9c9f4b3e88b79778503fd Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 26 Dec 2009 13:55:22 +0200 Subject: [PATCH] dbus: Check that wpa_s->scan_res != NULL before dereferencing it --- wpa_supplicant/dbus/dbus_new.c | 2 +- wpa_supplicant/dbus/dbus_new_handlers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 917de49f1..8674c889f 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1640,7 +1640,7 @@ static int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s) return 0; /* unregister all BSSs and networks from dbus */ - for (i = 0; i < wpa_s->scan_res->num; i++) { + for (i = 0; wpa_s->scan_res && i < wpa_s->scan_res->num; i++) { wpas_dbus_unregister_bss(wpa_s, wpa_s->scan_res->res[i]->bssid); } diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 601a0caf0..8ed95cb6c 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -188,7 +188,7 @@ static struct wpa_scan_res * find_scan_result(struct bss_handler_args *bss) { struct wpa_scan_results *results = bss->wpa_s->scan_res; size_t i; - for (i = 0; i < results->num; i++) { + for (i = 0; results && i < results->num; i++) { if (!os_memcmp(results->res[i]->bssid, bss->bssid, ETH_ALEN)) return results->res[i]; } @@ -2287,7 +2287,7 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message, if (!is_zero_ether_addr(wpa_s->bssid)) { size_t i; - for (i = 0; i < wpa_s->scan_res->num; i++) { + for (i = 0; wpa_s->scan_res && i < wpa_s->scan_res->num; i++) { struct wpa_scan_res *res = wpa_s->scan_res->res[i]; if (!os_memcmp(wpa_s->bssid, res->bssid, ETH_ALEN)) { is_bssid_known = 1;