ignatenkobrain / rpms / nginx

Forked from rpms/nginx 2 years ago
Clone
Igor Raits 290b06
From 9f1dcb0c0473641730b871dee984016ff19d2c53 Mon Sep 17 00:00:00 2001
Igor Raits 290b06
From: Maxim Dounin <mdounin@mdounin.ru>
Igor Raits 290b06
Date: Tue, 25 May 2021 15:17:36 +0300
Igor Raits 290b06
Subject: [PATCH] Resolver: fixed off-by-one write in ngx_resolver_copy().
Igor Raits 290b06
Igor Raits 290b06
Reported by Luis Merino, Markus Vervier, Eric Sesterhenn, X41 D-Sec GmbH.
Igor Raits 290b06
---
Igor Raits 290b06
 src/core/ngx_resolver.c | 8 ++++----
Igor Raits 290b06
 1 file changed, 4 insertions(+), 4 deletions(-)
Igor Raits 290b06
Igor Raits 290b06
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
Igor Raits 290b06
index 7939070102..63b26193df 100644
Igor Raits 290b06
--- a/src/core/ngx_resolver.c
Igor Raits 290b06
+++ b/src/core/ngx_resolver.c
Igor Raits 290b06
@@ -4008,15 +4008,15 @@ ngx_resolver_copy(ngx_resolver_t *r, ngx_str_t *name, u_char *buf, u_char *src,
Igor Raits 290b06
             n = *src++;
Igor Raits 290b06
 
Igor Raits 290b06
         } else {
Igor Raits 290b06
+            if (dst != name->data) {
Igor Raits 290b06
+                *dst++ = '.';
Igor Raits 290b06
+            }
Igor Raits 290b06
+
Igor Raits 290b06
             ngx_strlow(dst, src, n);
Igor Raits 290b06
             dst += n;
Igor Raits 290b06
             src += n;
Igor Raits 290b06
 
Igor Raits 290b06
             n = *src++;
Igor Raits 290b06
-
Igor Raits 290b06
-            if (n != 0) {
Igor Raits 290b06
-                *dst++ = '.';
Igor Raits 290b06
-            }
Igor Raits 290b06
         }
Igor Raits 290b06
 
Igor Raits 290b06
         if (n == 0) {