netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/rds: using strlcpy instead of strncpy
@ 2013-02-28  8:28 Chen Gang
  2013-02-28  9:36 ` David Laight
  0 siblings, 1 reply; 15+ messages in thread
From: Chen Gang @ 2013-02-28  8:28 UTC (permalink / raw)
  To: venkat.x.venkatsubra, David Miller, rds-devel, netdev


  when src strlen is sizeof(ctr.name) - 1, the dest str is not '\0' end.
  better use strlcpy instead.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 net/rds/stats.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/rds/stats.c b/net/rds/stats.c
index 7be790d..b9ac1df 100644
--- a/net/rds/stats.c
+++ b/net/rds/stats.c
@@ -86,7 +86,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);
+		strlcpy(ctr.name, names[i], sizeof(ctr.name));
 		ctr.value = values[i];
 
 		rds_info_copy(iter, &ctr, sizeof(ctr));
-- 
1.7.7.6

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

end of thread, other threads:[~2013-03-08  6:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-28  8:28 [PATCH] net/rds: using strlcpy instead of strncpy Chen Gang
2013-02-28  9:36 ` David Laight
2013-02-28 10:26   ` Chen Gang
2013-03-04 18:32   ` Ben Hutchings
2013-03-04 18:34     ` Ben Hutchings
2013-03-05  2:32       ` Chen Gang
2013-03-05  3:16         ` Ben Hutchings
2013-03-05  3:32           ` Chen Gang
2013-03-05  3:37             ` Ben Hutchings
2013-03-05  4:09               ` Chen Gang
2013-03-05 17:00                 ` Ben Hutchings
2013-03-07  4:03                   ` Chen Gang
2013-03-08  3:19                   ` [PATCH] net/rds: zero last byte for strncpy Chen Gang
2013-03-08  5:36                     ` David Miller
2013-03-08  6:13                       ` Chen Gang

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).