Skip to content

Commit

Permalink
net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'
Browse files Browse the repository at this point in the history
'snprintf' returns the number of characters which would have been written
if enough space had been available, excluding the terminating null byte.
Thus, the return value of 'sizeof(buf)' means that the last character
has been dropped.

Signed-off-by: Fedor Tokarev <[email protected]>
Fixes: 2f34b8b ("SUNRPC: add links for all client xprts to debugfs")
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
ftokarev authored and Trond Myklebust committed Dec 2, 2020
1 parent d3ff46f commit 35a6d39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/sunrpc/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *n
return 0;
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
xprt->debugfs->d_name.name);
if (len > sizeof(name))
if (len >= sizeof(name))
return -1;
if (*nump == 0)
strcpy(link, "xprt");
else {
len = snprintf(link, sizeof(link), "xprt%d", *nump);
if (len > sizeof(link))
if (len >= sizeof(link))
return -1;
}
debugfs_create_symlink(link, clnt->cl_debugfs, name);
Expand Down

0 comments on commit 35a6d39

Please sign in to comment.