Skip to content

Commit 84a7c0b

Browse files
manuelsdavem330
authored andcommitted
dns_resolver: assure that dns_query() result is null-terminated
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>
1 parent 2346829 commit 84a7c0b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/dns_resolver/dns_query.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ int dns_query(const char *type, const char *name, size_t namelen,
149149
if (!*_result)
150150
goto put;
151151

152-
memcpy(*_result, upayload->data, len + 1);
152+
memcpy(*_result, upayload->data, len);
153+
*_result[len] = '\0';
154+
153155
if (_expiry)
154156
*_expiry = rkey->expiry;
155157

0 commit comments

Comments
 (0)