]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
UBSan: Avoid memcmp(ptr, NULL, 0)
authorJouni Malinen <j@w1.fi>
Sat, 23 Feb 2019 11:50:47 +0000 (13:50 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 25 Feb 2019 17:48:49 +0000 (19:48 +0200)
Skip the memcmp() call if ssid_len == 0 and entry->ssid might be NULL to
avoid an UBSan warning.

wpa_supplicant.c:3956:9: runtime error: null pointer passed as argument 2, which is declared to never be null

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/wpa_supplicant.c

index c2e4218c5d2b3ff0cd73fd165042a8655bd386fe..20ae588ad18800a1446615003b9bb46dae914def 100644 (file)
@@ -3953,7 +3953,9 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
        while (entry) {
                if (!wpas_network_disabled(wpa_s, entry) &&
                    ((ssid_len == entry->ssid_len &&
-                     os_memcmp(ssid, entry->ssid, ssid_len) == 0) || wired) &&
+                     (!entry->ssid ||
+                      os_memcmp(ssid, entry->ssid, ssid_len) == 0)) ||
+                    wired) &&
                    (!entry->bssid_set ||
                     os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0))
                        return entry;