aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2014-12-19 18:01:35 -0500
committerJ. Bruce Fields <bfields@redhat.com>2015-01-07 14:48:10 -0500
commit0ec016e3e02fe07e7250b87daffab611f219e7f1 (patch)
tree220f651e1ee2843b7c6b2fda5e1d9d99dd6ec0a5
parent67db10344816c74709271c30905bb83781e7050c (diff)
nfsd4: tweak rd_dircount accounting
RFC 3530 14.2.24 says This value represents the length of the names of the directory entries and the cookie value for these entries. This length represents the XDR encoding of the data (names and cookies)... The "xdr encoding" of the name should probably include the 4 bytes for the length. But this is all just a hint so not worth e.g. backporting to stable. Also reshuffle some lines to more clearly group together the dircount-related code. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/nfs4xdr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 15f7b73e0c0f..91f7a3644ffb 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2768,16 +2768,17 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2768 if (entry_bytes > cd->rd_maxcount) 2768 if (entry_bytes > cd->rd_maxcount)
2769 goto fail; 2769 goto fail;
2770 cd->rd_maxcount -= entry_bytes; 2770 cd->rd_maxcount -= entry_bytes;
2771 if (!cd->rd_dircount)
2772 goto fail;
2773 /* 2771 /*
2774 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so 2772 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so
2775 * let's always let through the first entry, at least: 2773 * let's always let through the first entry, at least:
2776 */ 2774 */
2777 name_and_cookie = 4 * XDR_QUADLEN(namlen) + 8; 2775 if (!cd->rd_dircount)
2776 goto fail;
2777 name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
2778 if (name_and_cookie > cd->rd_dircount && cd->cookie_offset) 2778 if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
2779 goto fail; 2779 goto fail;
2780 cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie); 2780 cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
2781
2781 cd->cookie_offset = cookie_offset; 2782 cd->cookie_offset = cookie_offset;
2782skip_entry: 2783skip_entry:
2783 cd->common.err = nfs_ok; 2784 cd->common.err = nfs_ok;