Skip to content

Commit cd5599c

Browse files
committed
Check if SSID and BSSID properties were fetched
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().
1 parent f2cd15f commit cd5599c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/platform/Linux/ConnectivityManagerImpl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi
15491549
std::unique_ptr<GVariant, GVariantDeleter> ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID"));
15501550
std::unique_ptr<GVariant, GVariantDeleter> bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID"));
15511551

1552+
// Network scan is performed in the background, so the BSS
1553+
// may be gone when we try to get the properties.
1554+
if (ssid == nullptr || bssid == nullptr)
1555+
{
1556+
ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath);
1557+
return false;
1558+
}
1559+
15521560
const guchar * ssidStr = nullptr;
15531561
const guchar * bssidBuf = nullptr;
15541562
char bssidStr[2 * 6 + 5 + 1] = { 0 };

src/platform/webos/ConnectivityManagerImpl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,14 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi
15181518
std::unique_ptr<GVariant, GVariantDeleter> ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID"));
15191519
std::unique_ptr<GVariant, GVariantDeleter> bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID"));
15201520

1521+
// Network scan is performed in the background, so the BSS
1522+
// may be gone when we try to get the properties.
1523+
if (ssid == nullptr || bssid == nullptr)
1524+
{
1525+
ChipLogDetail(DeviceLayer, "wpa_supplicant: BSS not found: %s", bssPath);
1526+
return false;
1527+
}
1528+
15211529
const guchar * ssidStr = nullptr;
15221530
const guchar * bssidBuf = nullptr;
15231531
char bssidStr[2 * 6 + 5 + 1] = { 0 };

0 commit comments

Comments
 (0)