[nginx] svn commit: r4268 - trunk/src/core

igor at sysoev.ru igor at sysoev.ru
Wed Nov 9 13:54:07 UTC 2011


Author: is
Date: 2011-11-09 13:54:07 +0000 (Wed, 09 Nov 2011)
New Revision: 4268

Modified:
   trunk/src/core/ngx_resolver.c
Log:
Fixed compression pointer processing in DNS response greater than 255 bytes.

Thanks to Ben Hawkes.


Modified: trunk/src/core/ngx_resolver.c
===================================================================
--- trunk/src/core/ngx_resolver.c	2011-11-08 13:48:23 UTC (rev 4267)
+++ trunk/src/core/ngx_resolver.c	2011-11-09 13:54:07 UTC (rev 4268)
@@ -1952,7 +1952,13 @@
     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 @@
             if (n != 0) {
                 *dst++ = '.';
             }
-
-        } else {
-            n = ((n & 0x3f) << 8) + *src;
-            src = &buf[n];
-
-            n = *src++;
         }
 
         if (n == 0) {



More information about the nginx-devel mailing list