Replaced strncpy() with g_strlcpy() in wifi-power.c 65/139065/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 17 Jul 2017 06:38:44 +0000 (15:38 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 17 Jul 2017 06:39:43 +0000 (15:39 +0900)
strncpy doesn’t set zero byte implicitly.
Therefore it is wrong to assume that strlen returns correct length if mac_addr larger than rand_addr.

Change-Id: I8fe4c3e44356e7dfbe311e55604447417d21289c

packaging/net-config.spec
src/wifi-power.c

index c55af45..f7e2c1b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.1.109
+Version:       1.1.110
 Release:       2
 Group:         System/Network
 License:       Apache-2.0
index c0236c7..6c50357 100755 (executable)
@@ -24,6 +24,7 @@
 #include <TapiUtility.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <glib.h>
 #include <tzplatform_config.h>
 
 #if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
@@ -1058,8 +1059,7 @@ void __netconfig_set_ether_macaddr()
 
                netconfig_set_vconf_str(VCONF_ETH_MAC_ADDRESS, rand_addr);
        } else { /* Valid MAC address */
-               strncpy(rand_addr, mac_addr, strlen(mac_addr));
-               rand_addr[strlen(mac_addr)] = '\0';
+               g_strlcpy(rand_addr, mac_addr, WLAN_MAC_ADDR_MAX);
        }
 
        DBG("MAC Address of eth0 [%s]", rand_addr);