From db7b068b863424cae790e50a92f0e4a3bbb83b32 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Tue, 11 May 2021 19:10:22 +0900 Subject: [PATCH] Use memmove to prevent memory overlapping Change-Id: I1d7b95a72327b8d86a8b353b4dab0879ed59ee1d Signed-off-by: Cheoleun Moon --- plugins/libwebsockets/libwebsockets-plugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/libwebsockets/libwebsockets-plugin.cpp b/plugins/libwebsockets/libwebsockets-plugin.cpp index 3c10534..9ae9149 100755 --- a/plugins/libwebsockets/libwebsockets-plugin.cpp +++ b/plugins/libwebsockets/libwebsockets-plugin.cpp @@ -160,7 +160,10 @@ static void _get_peer_network_info(struct lws *wsi, inet_ntop(AF_INET6, &s->sin6_addr, ip, INET6_ADDRSTRLEN); if (__is_ipv4_mapped(ip)) { int ip_len = strlen(ip) - IPV4_MAPPED_IPv6_PREFIX_LEN; - strncpy(ip, ip + IPV4_MAPPED_IPv6_PREFIX_LEN, ip_len); + if (ip_len < 0) + ip_len = 0; + else + memmove(ip, ip + IPV4_MAPPED_IPv6_PREFIX_LEN, ip_len); ip[ip_len] = 0; *family = VINE_DP_IPV4; } -- 2.7.4