]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Fix segmentation fault when calling hostapd_cli all_sta
authorIlan Peer <ilan.peer@intel.com>
Wed, 22 Jan 2014 14:05:46 +0000 (16:05 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 22 Jan 2014 17:28:57 +0000 (19:28 +0200)
While iterating over the stations hostapd_ctrl_iface_sta_mib()
might be called with sta == NULL. Fix this.

Signed-hostap: Ilan Peer <ilan.peer@intel.com>

src/ap/ctrl_iface_ap.c

index 3fb9e04bbf7499a102734438f68ac249ca4ab4ea..8c0cbab665ea84801c3cc88ab1f68def1c56b44e 100644 (file)
@@ -86,6 +86,9 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
 {
        int len, res, ret, i;
 
+       if (!sta)
+               return 0;
+
        len = 0;
        ret = os_snprintf(buf + len, buflen - len, MACSTR "\nflags=",
                          MAC2STR(sta->addr));
@@ -203,7 +206,11 @@ int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
                if (ret < 0 || (size_t) ret >= buflen)
                        return 0;
                return ret;
-       }               
+       }
+
+       if (!sta->next)
+               return 0;
+
        return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
 }