dns_resolver: Do not accept domain names longer than 255 chars
authorManuel Schölling <manuel.schoelling@gmx.de>
Sat, 31 May 2014 21:37:40 +0000 (23:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Jun 2014 07:05:53 +0000 (00:05 -0700)
According to RFC1035 "[...] the total length of a domain name (i.e.,
label octets and label length octets) is restricted to 255 octets or
less."

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dns_resolver/dns_query.c

index e7b6d53eef88d250d6a93e3a75f26c3a6cad4cba..5b499589613fb90c018973257eb9c6139243bb98 100644 (file)
@@ -93,8 +93,8 @@ int dns_query(const char *type, const char *name, size_t namelen,
        }
 
        if (!namelen)
-               namelen = strlen(name);
-       if (namelen < 3)
+               namelen = strnlen(name, 256);
+       if (namelen < 3 || namelen > 255)
                return -EINVAL;
        desclen += namelen + 1;