From: Jukka Rissanen Date: Fri, 1 Jun 2012 12:02:07 +0000 (+0300) Subject: dnsproxy: Use memmove() when discarding domain name X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ca02c55add42f4d25114c77de9ef020221e7ab8;p=profile%2Fivi%2Fconnman.git dnsproxy: Use memmove() when discarding domain name The memory areas can overlap so memmove() must be used. --- diff --git a/src/dnsproxy.c b/src/dnsproxy.c index f56c30c..49651a2 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -1565,7 +1565,11 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol, * name. In this case we end up in this branch. */ if (domain_len > 0) { - memcpy(ptr + host_len + 1, + /* + * Note that we must use memmove() here, + * because the memory areas can overlap. + */ + memmove(ptr + host_len + 1, ptr + host_len + domain_len + 1, reply_len - (ptr - reply + domain_len));