[nginx] Resolver: fixed off-by-one write in ngx_resolver_copy().

Maxim Dounin mdounin at mdounin.ru
Tue May 25 15:34:10 UTC 2021


details:   https://hg.nginx.org/nginx/rev/7f702d35ac38
branches:  stable-1.20
changeset: 7858:7f702d35ac38
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue May 25 15:17:36 2021 +0300
description:
Resolver: fixed off-by-one write in ngx_resolver_copy().

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

diffstat:

 src/core/ngx_resolver.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (23 lines):

diff -r 76871d1340ea -r 7f702d35ac38 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Tue May 25 15:29:54 2021 +0300
+++ b/src/core/ngx_resolver.c	Tue May 25 15:17:36 2021 +0300
@@ -4008,15 +4008,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) {


More information about the nginx-devel mailing list