Replaced strncpy() with g_strlcpy() in wifi-power.c 71/139071/1 accepted/tizen/3.0/common/20170724.045637 accepted/tizen/3.0/ivi/20170724.032235 accepted/tizen/3.0/mobile/20170724.032219 accepted/tizen/3.0/tv/20170724.032230 submit/tizen_3.0/20170717.233800 submit/tizen_3.0/20170721.064109
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 17 Jul 2017 07:08:09 +0000 (16:08 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 17 Jul 2017 07:08:59 +0000 (16:08 +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: I99b80a2ce1dce5532113deed816bb9faaf554e40

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

index 2fda630..b3e4057 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.1.99
+Version:       1.1.100
 Release:       2
 Group:         System/Network
 License:       Apache-2.0
index dc7aa9e..28df80c 100755 (executable)
@@ -23,6 +23,7 @@
 #include <ITapiSim.h>
 #include <TapiUtility.h>
 #include <stdio.h>
+#include <glib.h>
 #include <tzplatform_config.h>
 
 #if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
@@ -1066,8 +1067,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);