aboutsummaryrefslogtreecommitdiff
path: root/ares
diff options
context:
space:
mode:
authorSteinar H. Gunderson <sesse@google.com>2007-09-29 13:38:17 +0000
committerSteinar H. Gunderson <sesse@google.com>2007-09-29 13:38:17 +0000
commit6ecea9453ba158edb1949dcac2fc46e1ad4b5bf2 (patch)
tree7b66eab3b04723793bdf0991b3b1465a46763032 /ares
parent2c105af910df6a607989143fb14a7ae67b17a9c9 (diff)
Handle the root of the DNS tree correctly in ares_expand_name.
Diffstat (limited to 'ares')
-rw-r--r--ares/ares_expand_name.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ares/ares_expand_name.c b/ares/ares_expand_name.c
index 7fe025fe4..ffa26e6b5 100644
--- a/ares/ares_expand_name.c
+++ b/ares/ares_expand_name.c
@@ -74,6 +74,14 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
return ARES_ENOMEM;
q = *s;
+ if (len == 0) {
+ // RFC2181 says this should be ".": the root of the DNS tree.
+ // Since this function strips trailing dots though, it becomes ""
+ q[0] = '\0';
+ *enclen = 1; // the caller should move one byte to get past this
+ return ARES_SUCCESS;
+ }
+
/* No error-checking necessary; it was all done by name_length(). */
p = encoded;
while (*p)