[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <513958C4.1020404@asianux.com>
Date: Fri, 08 Mar 2013 11:19:32 +0800
From: Chen Gang <gang.chen@...anux.com>
To: Ben Hutchings <bhutchings@...arflare.com>
CC: David Laight <David.Laight@...LAB.COM>,
venkat.x.venkatsubra@...cle.com,
David Miller <davem@...emloft.net>, rds-devel@....oracle.com,
netdev <netdev@...r.kernel.org>
Subject: [PATCH] net/rds: zero last byte for strncpy
for NUL terminated string, need be always sure '\0' in the end.
additional info:
strncpy will pads with zeroes to the end of the given buffer.
should initialise every bit of memory that is going to be copied to userland
Signed-off-by: Chen Gang <gang.chen@...anux.com>
Signed-off-by: Ben Hutchings <bhutchings@...arflare.com>
---
net/rds/stats.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/rds/stats.c b/net/rds/stats.c
index 7be790d..73be187 100644
--- a/net/rds/stats.c
+++ b/net/rds/stats.c
@@ -87,6 +87,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter,
for (i = 0; i < nr; i++) {
BUG_ON(strlen(names[i]) >= sizeof(ctr.name));
strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
+ ctr.name[sizeof(ctr.name) - 1] = '\0';
ctr.value = values[i];
rds_info_copy(iter, &ctr, sizeof(ctr));
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists