logging: net: Avoid copying too much data

Use strncpy() in order to avoid copying extra data to hostname buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-04-02 17:59:34 +03:00 committed by Anas Nashif
commit ea1bed4744

View file

@ -111,7 +111,7 @@ static int do_net_init(void)
}
if (IS_ENABLED(CONFIG_NET_HOSTNAME_ENABLE)) {
(void)memcpy(hostname, net_hostname_get(), MAX_HOSTNAME_LEN);
(void)strncpy(hostname, net_hostname_get(), MAX_HOSTNAME_LEN);
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
server_addr.sa_family == AF_INET6) {