Commit bba87648 authored by Manuel Schölling's avatar Manuel Schölling Committed by Ben Hutchings

dns_resolver: assure that dns_query() result is null-terminated

[ Upstream commit 84a7c0b1 ]

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: default avatarManuel Schölling <manuel.schoelling@gmx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 8b9b0927
...@@ -150,7 +150,9 @@ int dns_query(const char *type, const char *name, size_t namelen, ...@@ -150,7 +150,9 @@ int dns_query(const char *type, const char *name, size_t namelen,
if (!*_result) if (!*_result)
goto put; goto put;
memcpy(*_result, upayload->data, len + 1); memcpy(*_result, upayload->data, len);
*_result[len] = '\0';
if (_expiry) if (_expiry)
*_expiry = rkey->expiry; *_expiry = rkey->expiry;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment