From 518a4635e0255b9aa431f3a61d4e3900bf06b9ca Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 17 Jul 2017 16:08:09 +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: I99b80a2ce1dce5532113deed816bb9faaf554e40 --- 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 2fda630..b3e4057 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.99 +Version: 1.1.100 Release: 2 Group: System/Network License: Apache-2.0 diff --git a/src/wifi-power.c b/src/wifi-power.c index dc7aa9e..28df80c 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #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); -- 2.7.4