From 10752592bf7d204ba9c215584dcc6857a6b1bca3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 30 Sep 2022 23:35:33 +0200 Subject: [PATCH] Check if SSID and BSSID properties were fetched (#22930) Network scan is performed in the background by wpa_supplicant. When we are trying to get BSS properties, the BSS may be already gone. This patch prevents passing NULL to g_variant_get_fixed_array(). --- src/platform/Linux/ConnectivityManagerImpl.cpp | 8 ++++++++ src/platform/webos/ConnectivityManagerImpl.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index ee522b39c795a7..449527de2ee611 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1549,6 +1549,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi std::unique_ptr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); std::unique_ptr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); + // Network scan is performed in the background, so the BSS + // may be gone when we try to get the properties. + if (ssid == nullptr || bssid == nullptr) + { + ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath); + return false; + } + const guchar * ssidStr = nullptr; const guchar * bssidBuf = nullptr; char bssidStr[2 * 6 + 5 + 1] = { 0 }; diff --git a/src/platform/webos/ConnectivityManagerImpl.cpp b/src/platform/webos/ConnectivityManagerImpl.cpp index ed43cd38f7d710..627fa14366ce1f 100644 --- a/src/platform/webos/ConnectivityManagerImpl.cpp +++ b/src/platform/webos/ConnectivityManagerImpl.cpp @@ -1518,6 +1518,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi std::unique_ptr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); std::unique_ptr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); + // Network scan is performed in the background, so the BSS + // may be gone when we try to get the properties. + if (ssid == nullptr || bssid == nullptr) + { + ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath); + return false; + } + const guchar * ssidStr = nullptr; const guchar * bssidBuf = nullptr; char bssidStr[2 * 6 + 5 + 1] = { 0 };