diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-03-20 21:20:26 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-30 17:32:04 -0400 |
commit | 3b299709091befc0e02aa33d55ddd5baef006853 (patch) | |
tree | 2d514a4417d20b1a374d8d862ecc787ea0543936 /fs/nfsd/nfs4xdr.c | |
parent | 561f0ed498ca4342573a870779cc645d3fd7dfe7 (diff) |
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: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 4d79e5366a82..3f2a52ccb9d1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1033,7 +1033,7 @@ nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *read | |||
1033 | READ_BUF(24); | 1033 | READ_BUF(24); |
1034 | READ64(readdir->rd_cookie); | 1034 | READ64(readdir->rd_cookie); |
1035 | COPYMEM(readdir->rd_verf.data, sizeof(readdir->rd_verf.data)); | 1035 | COPYMEM(readdir->rd_verf.data, sizeof(readdir->rd_verf.data)); |
1036 | READ32(readdir->rd_dircount); /* just in case you needed a useless field... */ | 1036 | READ32(readdir->rd_dircount); |
1037 | READ32(readdir->rd_maxcount); | 1037 | READ32(readdir->rd_maxcount); |
1038 | if ((status = nfsd4_decode_bitmap(argp, readdir->rd_bmval))) | 1038 | if ((status = nfsd4_decode_bitmap(argp, readdir->rd_bmval))) |
1039 | goto out; | 1039 | goto out; |
@@ -2720,6 +2720,9 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, | |||
2720 | if (entry_bytes > cd->rd_maxcount) | 2720 | if (entry_bytes > cd->rd_maxcount) |
2721 | goto fail; | 2721 | goto fail; |
2722 | cd->rd_maxcount -= entry_bytes; | 2722 | cd->rd_maxcount -= entry_bytes; |
2723 | if (!cd->rd_dircount) | ||
2724 | goto fail; | ||
2725 | cd->rd_dircount--; | ||
2723 | cd->cookie_offset = cookie_offset; | 2726 | cd->cookie_offset = cookie_offset; |
2724 | skip_entry: | 2727 | skip_entry: |
2725 | cd->common.err = nfs_ok; | 2728 | cd->common.err = nfs_ok; |