Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e85d676 authored by Chen Gang's avatar Chen Gang Committed by David S. Miller
Browse files

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: default avatarChen Gang <gang.chen@asianux.com>
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9169323
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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));