From f1e11458f4832d08dfc6d110d56e0b4ad10bce72 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Wed, 19 Aug 2020 16:39:29 +0900 Subject: [PATCH] Replace char* with char[] for mac address Change-Id: I747861dc6ca9d4d496cc73c3d4f93c6df47368a2 --- include/wifi_internal.h | 4 ++-- src/network_internal.c | 8 +------- src/network_signal.c | 2 +- src/wifi_internal.c | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/wifi_internal.h b/include/wifi_internal.h index 7db289d..bc3a326 100755 --- a/include/wifi_internal.h +++ b/include/wifi_internal.h @@ -300,12 +300,12 @@ typedef struct { typedef struct { int type; - char *mac_add; + char mac_add[WIFI_MAC_ADDR_LEN + 1]; } net_tdls_discover_s; typedef struct { GSList *ssids; - char vsie[NET_WLAN_MAX_VSIE_LEN+1]; + char vsie[NET_WLAN_MAX_VSIE_LEN + 1]; } wifi_netlink_scan_s; /* WIFI Manager */ diff --git a/src/network_internal.c b/src/network_internal.c index 91d5925..3a764c9 100755 --- a/src/network_internal.c +++ b/src/network_internal.c @@ -356,13 +356,7 @@ int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_i static void __net_client_clear_cb_data(net_event_info_s *client) { if (client && client->Datalength > 0) { - if (client->Event == NET_EVENT_WIFI_TDLS_DISCOVERED_IND) { - net_tdls_discover_s *discover_info = client->Data; - - if (discover_info != NULL) - g_free(discover_info->mac_add); - - } else if (client->Event == NET_EVENT_WIFI_SPECIFIC_SCAN_IND || + if (client->Event == NET_EVENT_WIFI_SPECIFIC_SCAN_IND || client->Event == NET_EVENT_WIFI_BSSID_SCAN_IND || client->Event == NET_EVENT_WIFI_NETLINK_SCAN_IND) { GSList *bss_info_list = client->Data; diff --git a/src/network_signal.c b/src/network_signal.c index ff06f78..7f0e4d4 100755 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -1042,7 +1042,7 @@ static int __net_handle_wifi_tdls_discover_event(GVariant *param) while (g_variant_iter_loop(iter, "{sv}", &key, &value)) { if (g_strcmp0(key, "peermac") == 0) { sig_value = g_variant_get_string(value, NULL); - discover_info.mac_add = g_strdup(sig_value); + g_strlcpy(discover_info.mac_add, sig_value, WIFI_MAC_ADDR_LEN + 1); WIFI_LOG(WIFI_INFO, "TDLS discovered Peer Mac Address: %s", discover_info.mac_add); } else if (g_strcmp0(key, "discover_type") == 0) { diff --git a/src/wifi_internal.c b/src/wifi_internal.c index d3b1b4b..7e947a2 100755 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -1102,7 +1102,6 @@ static void __tdls_discovered_cb(net_event_info_s *event_cb) local_handle->tdls_discovered_user_data); } } - g_free(discover_info->mac_add); } -- 2.7.4