Skip to content

Commit

Permalink
NFS: Fix a readdirplus bug
Browse files Browse the repository at this point in the history
When comparing filehandles in the helper nfs_same_file(), we should not be
using 'strncmp()': filehandles are not null terminated strings.

Instead, we should just use the existing helper nfs_compare_fh().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Trond Myklebust authored and Linus Torvalds committed Nov 30, 2010
1 parent e8a7e48 commit 37a09f0
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,9 @@ int xdr_decode(nfs_readdir_descriptor_t *desc, struct nfs_entry *entry, struct x
static
int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
{
struct nfs_inode *node;
if (dentry->d_inode == NULL)
goto different;
node = NFS_I(dentry->d_inode);
if (node->fh.size != entry->fh->size)
goto different;
if (strncmp(node->fh.data, entry->fh->data, node->fh.size) != 0)
if (nfs_compare_fh(entry->fh, NFS_FH(dentry->d_inode)) != 0)
goto different;
return 1;
different:
Expand Down

0 comments on commit 37a09f0

Please sign in to comment.