Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount
@ 2024-01-25 14:42 Jorge Mora
  2024-01-25 17:02 ` Jeff Layton
  2024-01-25 18:03 ` Chuck Lever
  0 siblings, 2 replies; 3+ messages in thread
From: Jorge Mora @ 2024-01-25 14:42 UTC (permalink / raw)
  To: linux-nfs; +Cc: chuck.lever, jlayton

The maxcount is the maximum number of bytes for the LISTXATTRS4resok
result. This includes the cookie and the count for the name array,
thus subtract 12 bytes from the maxcount: 8 (cookie) + 4 (array count)
when filling up the name array.

Fixes: 23e50fe3a5e6 ("nfsd: implement the xattr functions and en/decode logic")
Signed-off-by: Jorge Mora <mora@netapp.com>
---
 fs/nfsd/nfs4xdr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 92c7dde148a4..17e6404f4296 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -5168,7 +5168,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
 	sp = listxattrs->lsxa_buf;
 	nuser = 0;
 
-	xdrleft = listxattrs->lsxa_maxcount;
+	/* Bytes left is maxcount - 8 (cookie) - 4 (array count) */
+	xdrleft = listxattrs->lsxa_maxcount - 12;
 
 	while (left > 0 && xdrleft > 0) {
 		slen = strlen(sp);
-- 
2.43.0


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

end of thread, other threads:[~2024-01-25 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 14:42 [PATCH] NFSD: fix LISTXATTRS returning more bytes than maxcount Jorge Mora
2024-01-25 17:02 ` Jeff Layton
2024-01-25 18:03 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox