diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-03-07 17:19:32 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-08 00:35:44 -0500 |
commit | 2e85d67690cf3ea3f074a6e872f675226883fe7f (patch) | |
tree | 12412103c1a5bfde782c1692231bd40844267c73 /net | |
parent | d9169323308a63fdd967920b9c63a00394ae7c85 (diff) | |
download | kernel-common-2e85d67690cf3ea3f074a6e872f675226883fe7f.tar.gz kernel-common-2e85d67690cf3ea3f074a6e872f675226883fe7f.tar.bz2 kernel-common-2e85d67690cf3ea3f074a6e872f675226883fe7f.zip |
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@asianux.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | 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 7be790d60b90..73be187d389e 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)); |