[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b97379d3bf59487d8d0ca3bbf14ad0df@bfs.de>
Date: Thu, 15 Oct 2020 15:04:46 +0000
From: Walter Harms <wharms@....de>
To: Fedor Tokarev <ftokarev@...il.com>,
"bfields@...ldses.org" <bfields@...ldses.org>,
"chuck.lever@...cle.com" <chuck.lever@...cle.com>,
"anna.schumaker@...app.com" <anna.schumaker@...app.com>,
"trond.myklebust@...merspace.com" <trond.myklebust@...merspace.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"kuba@...nel.org" <kuba@...nel.org>
CC: "linux-nfs@...r.kernel.org" <linux-nfs@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: AW: [PATCH] net: sunrpc: Fix 'snprintf' return value check in
'do_xprt_debugfs'
if xprt->debugfs->d_name.name can be what ever long
it is more clever to use kasprintf()
the some for link (no idea how many xprt als possible)
jm2c
wh
________________________________________
Von: Fedor Tokarev [ftokarev@...il.com]
Gesendet: Donnerstag, 15. Oktober 2020 15:59
An: bfields@...ldses.org; chuck.lever@...cle.com; anna.schumaker@...app.com; trond.myklebust@...merspace.com; davem@...emloft.net; kuba@...nel.org
Cc: linux-nfs@...r.kernel.org; netdev@...r.kernel.org; linux-kernel@...r.kernel.org; kernel-janitors@...r.kernel.org; ftokarev@...il.com
Betreff: [PATCH] net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'
'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 <ftokarev@...il.com>
---
net/sunrpc/debugfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index fd9bca2..56029e3 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -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);
--
2.7.4
Powered by blists - more mailing lists