Commit 3b299709 authored by J. Bruce Fields's avatar J. Bruce Fields
Browse files

nfsd4: enforce rd_dircount

As long as we're here, let's enforce the protocol's limit on the number
of directory entries to return in a readdir.

I don't think anyone's ever noticed our lack of enforcement, but maybe
there's more of a chance they will now that we allow larger readdirs.
Signed-off-by: default avatarJ. Bruce Fields <>
parent 561f0ed4
......@@ -1033,7 +1033,7 @@ nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *read
COPYMEM(readdir->, sizeof(readdir->;
READ32(readdir->rd_dircount); /* just in case you needed a useless field... */
if ((status = nfsd4_decode_bitmap(argp, readdir->rd_bmval)))
goto out;
......@@ -2720,6 +2720,9 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
if (entry_bytes > cd->rd_maxcount)
goto fail;
cd->rd_maxcount -= entry_bytes;
if (!cd->rd_dircount)
goto fail;
cd->cookie_offset = cookie_offset;
cd->common.err = nfs_ok;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment