* [patch] hfs: copying wrong data in hfs_readdir()
@ 2012-06-23 9:14 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2012-06-23 9:14 UTC (permalink / raw)
To: Al Viro; +Cc: Miklos Szeredi, linux-fsdevel, linux-kernel, kernel-janitors
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@oracle.com>
---
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-23 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-23 9:14 [patch] hfs: copying wrong data in hfs_readdir() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).