From a09486976553cf2e4b33a5d1a53dcef3d1464184 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Tue, 19 Dec 2023 20:01:20 +0900 Subject: [PATCH] Fix parsing of invalid devices If there are multiple devices, the remaining devices are parsed even after the desired device is found, so there is a problem in that the last parsed value is used as the final value. Therefore, it has been modified to not parse other devices if parsing of the desired device is completed. Change-Id: I90b77c2797a543dd4451252573dbd67a7213aca6 Signed-off-by: Jaehyun Kim --- src/network_internal.c | 8 +++++++- src/network_signal.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/network_internal.c b/src/network_internal.c index b9b3606..024a411 100644 --- a/src/network_internal.c +++ b/src/network_internal.c @@ -272,8 +272,14 @@ int _net_get_tech_state(network_info_s *network_info, sdata = g_variant_get_string(dev_var, NULL); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata); - if (g_strcmp0(dev_key, "Ifname") == 0) + if (g_strcmp0(dev_key, "Ifname") == 0) { + if (find) { + g_variant_unref(dev_var); + g_free(dev_key); + break; + } find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE; + } } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) { bdata = g_variant_get_boolean(dev_var); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False"); diff --git a/src/network_signal.c b/src/network_signal.c index a3e5c4b..4f5410c 100644 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -2122,10 +2122,16 @@ static int __net_get_tech_states(network_info_s *network_info, GVariant *message sdata = g_variant_get_string(dev_var, NULL); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, sdata); - if (g_strcmp0(dev_key, "Ifname") == 0) + if (g_strcmp0(dev_key, "Ifname") == 0) { + if (find) { + g_variant_unref(dev_var); + g_free(dev_key); + break; + } find = g_strcmp0(sdata, network_info->interface_name) == 0 ? TRUE : FALSE; - else if (find && g_strcmp0(dev_key, "MAC.Address") == 0) + } else if (find && g_strcmp0(dev_key, "MAC.Address") == 0) { g_strlcpy(network_info->mac_address, sdata, WIFI_MAC_ADDR_LEN + 1); + } } else if (g_variant_is_of_type(dev_var, G_VARIANT_TYPE_BOOLEAN)) { bdata = g_variant_get_boolean(dev_var); WIFI_LOG(WIFI_INFO, "%s [%s]", dev_key, bdata ? "True" : "False"); -- 2.7.4