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
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
#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
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);