ares_expand_name: Fix encoded length for indirect root
authorStefan Bühler <stbuehler@web.de>
Sat, 18 Dec 2010 13:17:09 +0000 (14:17 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 18 Dec 2010 16:23:04 +0000 (17:23 +0100)
ares_expand_name.c

index 2af6b2ac40b2fae976dcfb8249d06c47be13d028..e3eccd2f74d2e3591133985b81f02c4c7199df1d 100644 (file)
@@ -87,7 +87,14 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
      * Since this function strips trailing dots though, it becomes ""
      */
     q[0] = '\0';
-    *enclen = 1;  /* the caller should move one byte to get past this */
+
+    /* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
+       valid) */
+    if ((*encoded & INDIR_MASK) == INDIR_MASK)
+      *enclen = 2;
+    else
+      *enclen = 1;  /* the caller should move one byte to get past this */
+
     return ARES_SUCCESS;
   }