summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-24 11:52:55 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-24 13:18:04 -0400
commit9af8c222ca5eae88f000664f693316480bf58fbc (patch)
tree4b5f49ab95cd07884ef1b51cda671a18c3dd4a3d /fs
parent4f082222fad3c8471abe0c8e8f18c72f335a34c7 (diff)
downloadop-kernel-dev-9af8c222ca5eae88f000664f693316480bf58fbc.zip
op-kernel-dev-9af8c222ca5eae88f000664f693316480bf58fbc.tar.gz
NFSv4: Clean up nfs4_decode_dirent
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4xdr.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 9bf5e66..4c43e48 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -5803,11 +5803,10 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
p = xdr_decode_hyper(p, &entry->cookie);
entry->len = ntohl(*p++);
- p = xdr_inline_decode(xdr, entry->len + 4);
+ p = xdr_inline_decode(xdr, entry->len);
if (unlikely(!p))
goto out_overflow;
entry->name = (const char *) p;
- p += XDR_QUADLEN(entry->len);
/*
* In case the server doesn't return an inode number,
@@ -5817,30 +5816,19 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
entry->ino = 1;
entry->fattr->valid = 0;
- len = ntohl(*p++); /* bitmap length */
- if (len-- > 0) {
- p = xdr_inline_decode(xdr, 4);
- if (unlikely(!p))
- goto out_overflow;
- bitmap[0] = ntohl(*p++);
- if (len-- > 0) {
- p = xdr_inline_decode(xdr, 4);
- if (unlikely(!p))
- goto out_overflow;
- bitmap[1] = ntohl(*p++);
- p += len;
- }
- }
- p = xdr_inline_decode(xdr, 4);
- if (unlikely(!p))
+ if (decode_attr_bitmap(xdr, bitmap) < 0)
+ goto out_overflow;
+
+ if (decode_attr_length(xdr, &len, &p) < 0)
+ goto out_overflow;
+
+ if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, server, 1) < 0)
+ goto out_overflow;
+ if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
+ entry->ino = entry->fattr->fileid;
+
+ if (verify_attr_len(xdr, p, len) < 0)
goto out_overflow;
- len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */
- if (len > 0) {
- if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, server, 1) < 0)
- goto out_overflow;
- if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
- entry->ino = entry->fattr->fileid;
- }
p = xdr_inline_peek(xdr, 8);
if (p != NULL)
OpenPOWER on IntegriCloud