From 0e12e098221e7f979fe96f28b1501a98a8ef5f4c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 17 Jul 2017 15:38:44 +0900 Subject: [PATCH] Replaced strncpy() with g_strlcpy() in wifi-power.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 2 +- src/wifi-power.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/net-config.spec b/packaging/net-config.spec index c55af45..f7e2c1b 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -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 diff --git a/src/wifi-power.c b/src/wifi-power.c index c0236c7..6c50357 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #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); -- 2.7.4