[patch] hfs: copying wrong data in hfs_readdir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Smatch complains that this is copying stack data when then intent was
to copy fd.key.  The way I have written it matches how hfsplus_readdir()
is implemented.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
I tried to test this, but to reach the memcpy() you would need to make
one of the calls to filldir() fail and I don't know how to do that.  I
think that in the original code this would cause a crash when we call
hfs_find_exit()

diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 62fc14e..f637bd5 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -162,7 +162,7 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		rd->file = filp;
 		list_add(&rd->list, &HFS_I(inode)->open_dir_list);
 	}
-	memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key));
+	memcpy(&rd->key, fd.key, sizeof(struct hfs_cat_key));
 out:
 	hfs_find_exit(&fd);
 	return err;
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux