chiark / gitweb /
dns-domain: never allow labels that are larger than 63 chars
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Jul 2014 01:29:20 +0000 (03:29 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Jul 2014 01:29:20 +0000 (03:29 +0200)
src/resolve/resolved-dns-domain.c

index 33ae261..27739c1 100644 (file)
@@ -45,6 +45,9 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
                 if (sz <= 0)
                         return -ENOSPC;
 
+                if (r >= DNS_LABEL_MAX)
+                        return -EINVAL;
+
                 if (*n == '\\') {
                         /* Escaped character */
 
@@ -114,6 +117,9 @@ int dns_label_escape(const char *p, size_t l, char **ret) {
         assert(p);
         assert(ret);
 
+        if (l > DNS_LABEL_MAX)
+                return -EINVAL;
+
         s = malloc(l * 4 + 1);
         if (!s)
                 return -ENOMEM;