dnsproxy: Use memmove() when discarding domain name
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 1 Jun 2012 12:02:07 +0000 (15:02 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 7 Jun 2012 07:39:47 +0000 (10:39 +0300)
The memory areas can overlap so memmove() must be used.

src/dnsproxy.c

index f56c30c..49651a2 100644 (file)
@@ -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));