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