From: Cheoleun Moon Date: Tue, 11 May 2021 10:10:22 +0000 (+0900) Subject: Use memmove to prevent memory overlapping X-Git-Tag: submit/tizen/20210512.020301^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db7b068b863424cae790e50a92f0e4a3bbb83b32;p=platform%2Fcore%2Fapi%2Fvine.git Use memmove to prevent memory overlapping Change-Id: I1d7b95a72327b8d86a8b353b4dab0879ed59ee1d Signed-off-by: Cheoleun Moon --- 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; }