Skip to content

Commit

Permalink
dns_resolver: assure that dns_query() result is null-terminated
Browse files Browse the repository at this point in the history
dns_query() credulously assumes that keys are null-terminated and
returns a copy of a memory block that is off by one.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
manuels authored and davem330 committed Jun 11, 2014
1 parent 2346829 commit 84a7c0b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/dns_resolver/dns_query.c
Expand Up @@ -149,7 +149,9 @@ int dns_query(const char *type, const char *name, size_t namelen,
if (!*_result)
goto put;

memcpy(*_result, upayload->data, len + 1);
memcpy(*_result, upayload->data, len);
*_result[len] = '\0';

if (_expiry)
*_expiry = rkey->expiry;

Expand Down

0 comments on commit 84a7c0b

Please sign in to comment.