resolved: only suffix RR key names with a dot if they don't have one yet
authorLennart Poettering <lennart@poettering.net>
Sat, 2 Jan 2016 20:34:17 +0000 (21:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 2 Jan 2016 21:16:16 +0000 (22:16 +0100)
src/resolve/resolved-dns-rr.c

index 274e857..4d47f48 100644 (file)
@@ -308,7 +308,7 @@ const struct hash_ops dns_resource_key_hash_ops = {
 
 int dns_resource_key_to_string(const DnsResourceKey *key, char **ret) {
         char cbuf[strlen("CLASS") + DECIMAL_STR_MAX(uint16_t)], tbuf[strlen("TYPE") + DECIMAL_STR_MAX(uint16_t)];
-        const char *c, *t;
+        const char *c, *t, *n;
         char *s;
 
         /* If we cannot convert the CLASS/TYPE into a known string,
@@ -326,7 +326,8 @@ int dns_resource_key_to_string(const DnsResourceKey *key, char **ret) {
                 t = tbuf;
         }
 
-        if (asprintf(&s, "%s. %s %-5s", DNS_RESOURCE_KEY_NAME(key), c, t) < 0)
+        n = DNS_RESOURCE_KEY_NAME(key);
+        if (asprintf(&s, "%s%s %s %-5s", n, endswith(n, ".") ? "" : ".", c, t) < 0)
                 return -ENOMEM;
 
         *ret = s;