
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1621945056 -10800
# Node ID 7f702d35ac38abc358c0df154fd9c9e5df678395
# Parent  76871d1340eade38e71da8110dc63df8c4570aea
Resolver: fixed off-by-one write in ngx_resolver_copy().

Reported by Luis Merino, Markus Vervier, Eric Sesterhenn, X41 D-Sec GmbH.

--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -3993,15 +3993,15 @@ done:
             n = *src++;
 
         } else {
+            if (dst != name->data) {
+                *dst++ = '.';
+            }
+
             ngx_strlow(dst, src, n);
             dst += n;
             src += n;
 
             n = *src++;
-
-            if (n != 0) {
-                *dst++ = '.';
-            }
         }
 
         if (n == 0) {
