netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dns_resolver: assure that dns_query() result is null-terminated
@ 2014-06-07 17:56 Manuel Schölling
  2014-06-07 18:54 ` Trond Myklebust
  0 siblings, 1 reply; 10+ messages in thread
From: Manuel Schölling @ 2014-06-07 17:56 UTC (permalink / raw)
  To: davem; +Cc: jeffrey.t.kirsher, netdev, linux-kernel, Manuel Schölling

dns_query() credulously assumes that keys are null-terminated and
returns a copy of a memory block that is off by one.
---
 net/dns_resolver/dns_query.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index e7b6d53..53be635 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -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+1] = '\0';
+
 	if (_expiry)
 		*_expiry = rkey->expiry;
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-11  7:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-07 17:56 [PATCH] dns_resolver: assure that dns_query() result is null-terminated Manuel Schölling
2014-06-07 18:54 ` Trond Myklebust
2014-06-07 18:57   ` Manuel Schoelling
2014-06-07 19:01   ` [PATCH v2] " Manuel Schölling
2014-06-07 21:42     ` David Rientjes
2014-06-07 21:53       ` Manuel Schoelling
2014-06-07 22:02         ` David Rientjes
2014-06-07 21:57       ` Sergei Shtylyov
2014-06-07 21:57     ` [PATCH v3] " Manuel Schölling
2014-06-11  7:12       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).