From ea1bed4744d44e483bf3706a315e36e13356fa50 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 2 Apr 2020 17:59:34 +0300 Subject: [PATCH] logging: net: Avoid copying too much data Use strncpy() in order to avoid copying extra data to hostname buffer. Signed-off-by: Jukka Rissanen --- subsys/logging/log_backend_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/logging/log_backend_net.c b/subsys/logging/log_backend_net.c index 3a8ec1865bc..f04502563da 100644 --- a/subsys/logging/log_backend_net.c +++ b/subsys/logging/log_backend_net.c @@ -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) {