Skip to content

Commit

Permalink
NFSv4: Fix up decode_attr_filehandle() to handle the case of empty fh…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 23, 2010
1 parent 4a201d6 commit 7ad0735
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions fs/nfs/nfs4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2883,12 +2883,8 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru
__be32 *p;
int len;

if (fh == NULL) {
bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
return 0;
}

memset(fh, 0, sizeof(*fh));
if (fh != NULL)
memset(fh, 0, sizeof(*fh));

if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
return -EIO;
Expand All @@ -2899,11 +2895,13 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru
len = be32_to_cpup(p);
if (len > NFS4_FHSIZE)
return -EIO;
fh->size = len;
p = xdr_inline_decode(xdr, len);
if (unlikely(!p))
goto out_overflow;
memcpy(fh->data, p, len);
if (fh != NULL) {
memcpy(fh->data, p, len);
fh->size = len;
}
bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
}
return 0;
Expand Down

0 comments on commit 7ad0735

Please sign in to comment.