aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-23 15:34:20 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-23 15:34:20 -0400
commit7ad07353003d6ff69fe0b987813bb77b4d5ac23d (patch)
tree580d0284b6946454d9136b3568e69eb3524be8ed
parent4a201d6e3f4253f918555cc7c27c418f8ac1bb65 (diff)
NFSv4: Fix up decode_attr_filehandle() to handle the case of empty fh pointer
decode_attr_filehandle still needs to skip the XDR-encoded filehandle if someone passes a null pointer argument. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4xdr.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index ccfb1c92b262..a6b00e84bd1a 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -2883,12 +2883,8 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru
2883 __be32 *p; 2883 __be32 *p;
2884 int len; 2884 int len;
2885 2885
2886 if (fh == NULL) { 2886 if (fh != NULL)
2887 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; 2887 memset(fh, 0, sizeof(*fh));
2888 return 0;
2889 }
2890
2891 memset(fh, 0, sizeof(*fh));
2892 2888
2893 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) 2889 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
2894 return -EIO; 2890 return -EIO;
@@ -2899,11 +2895,13 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru
2899 len = be32_to_cpup(p); 2895 len = be32_to_cpup(p);
2900 if (len > NFS4_FHSIZE) 2896 if (len > NFS4_FHSIZE)
2901 return -EIO; 2897 return -EIO;
2902 fh->size = len;
2903 p = xdr_inline_decode(xdr, len); 2898 p = xdr_inline_decode(xdr, len);
2904 if (unlikely(!p)) 2899 if (unlikely(!p))
2905 goto out_overflow; 2900 goto out_overflow;
2906 memcpy(fh->data, p, len); 2901 if (fh != NULL) {
2902 memcpy(fh->data, p, len);
2903 fh->size = len;
2904 }
2907 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; 2905 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
2908 } 2906 }
2909 return 0; 2907 return 0;