From: Manuel Schölling Date: Sat, 31 May 2014 21:37:40 +0000 (+0200) Subject: dns_resolver: Do not accept domain names longer than 255 chars X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9638f6713ff556bdc34e9d18eeb7c1b25b35e5ce;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git dns_resolver: Do not accept domain names longer than 255 chars 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 Signed-off-by: David S. Miller --- diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index e7b6d53eef88..5b499589613f 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -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;