]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Avoid memcmp() with NULL pointer even if for zero length
authorSunil Ravi <sunilravi@google.com>
Fri, 20 Sep 2024 19:24:55 +0000 (19:24 +0000)
committerJouni Malinen <j@w1.fi>
Wed, 9 Oct 2024 16:34:30 +0000 (19:34 +0300)
Explicitly check for last_ssid->ssid to be set in wpa_bss_flush_by_age()
before using memcmp() to compare the SSID against the one in the BSS
entry. This is not really expected to do any real comparison here since
the case where last_ssid->ssid is NULL implies bss->ssid_len to be 0.
Anyway, avoid the unexpected memcmp(ptr, NULL, 0) call in such a case to
avoid issues with C libraries that might prevent such as unexpected
behavior.

Signed-off-by: Sunil Ravi <sunilravi@google.com>
wpa_supplicant/bss.c

index 39de8bac350f30aa691d7ad3a57d1c977e9217c8..35b62cbe945ade7da90786392bbf8b7babf5104f 100644 (file)
@@ -1083,6 +1083,7 @@ void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
                if (wpa_s->reassoc_same_ess &&
                    wpa_s->wpa_state != WPA_COMPLETED &&
                    wpa_s->last_ssid &&
+                   wpa_s->last_ssid->ssid &&
                    bss->ssid_len == wpa_s->last_ssid->ssid_len &&
                    os_memcmp(bss->ssid, wpa_s->last_ssid->ssid,
                              bss->ssid_len) == 0)