Skip to content

Commit 31e4bb8

Browse files
Jorge Morachucklever
authored andcommitted
NFSD: fix LISTXATTRS returning more bytes than maxcount
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: 23e50fe ("nfsd: implement the xattr functions and en/decode logic") Signed-off-by: Jorge Mora <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 2f73f37 commit 31e4bb8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5423,7 +5423,7 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
54235423
*/
54245424
cookie_offset = xdr->buf->len;
54255425
count_offset = cookie_offset + 8;
5426-
p = xdr_reserve_space(xdr, 12);
5426+
p = xdr_reserve_space(xdr, XDR_UNIT * 3);
54275427
if (!p) {
54285428
status = nfserr_resource;
54295429
goto out;
@@ -5434,7 +5434,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
54345434
sp = listxattrs->lsxa_buf;
54355435
nuser = 0;
54365436

5437-
xdrleft = listxattrs->lsxa_maxcount;
5437+
/* Bytes left is maxcount - 8 (cookie) - 4 (array count) */
5438+
xdrleft = listxattrs->lsxa_maxcount - XDR_UNIT * 3;
54385439

54395440
while (left > 0 && xdrleft > 0) {
54405441
slen = strlen(sp);

0 commit comments

Comments
 (0)