From 6cc6ee5f71dda5ed1669897e288e86ee3ecbc7e9 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Wed, 9 Nov 2011 13:54:07 +0000 Subject: [PATCH] Fixed compression pointer processing in DNS response greater than 255 bytes. Thanks to Ben Hawkes. --- src/core/ngx_resolver.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 268faa456..35818a7ae 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -1952,7 +1952,13 @@ done: n = *src++; for ( ;; ) { - if (n != 0xc0) { + if (n & 0xc0) { + n = ((n & 0x3f) << 8) + *src; + src = &buf[n]; + + n = *src++; + + } else { ngx_memcpy(dst, src, n); dst += n; src += n; @@ -1962,12 +1968,6 @@ done: if (n != 0) { *dst++ = '.'; } - - } else { - n = ((n & 0x3f) << 8) + *src; - src = &buf[n]; - - n = *src++; } if (n == 0) {