summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ares_expand_name.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ares_expand_name.c b/ares_expand_name.c
index 7fe025f..ffa26e6 100644
--- a/ares_expand_name.c
+++ b/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)