From f1dd1d50e090b32a765295daea5f167f1077d706 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Tue, 25 May 2021 15:17:43 +0300 Subject: [PATCH] Resolver: reworked ngx_resolver_copy() copy loop. To make the code easier to read, reworked the ngx_resolver_copy() copy loop to match the one used to calculate length. No functional changes. --- src/core/ngx_resolver.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 12dab09ea..0d7fd7915 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -4008,15 +4008,18 @@ done: name->data = dst; - n = *src++; - for ( ;; ) { + n = *src++; + + if (n == 0) { + name->len = dst - name->data; + return NGX_OK; + } + if (n & 0xc0) { n = ((n & 0x3f) << 8) + *src; src = &buf[n]; - n = *src++; - } else { if (dst != name->data) { *dst++ = '.'; @@ -4025,13 +4028,6 @@ done: ngx_strlow(dst, src, n); dst += n; src += n; - - n = *src++; - } - - if (n == 0) { - name->len = dst - name->data; - return NGX_OK; } } }