* [gentoo-commits] proj/qemu-kvm:qemu-kvm-1.1.2-gentoo commit in: linux-user/
@ 2013-01-19 3:47 Doug Goldstein
0 siblings, 0 replies; only message in thread
From: Doug Goldstein @ 2013-01-19 3:47 UTC (permalink / raw
To: gentoo-commits
commit: 8b1b3ed4d22dfec3b864041efd25f6de6a7a2fef
Author: Dmitry V. Levin <ldv <AT> altlinux <DOT> org>
AuthorDate: Mon Aug 20 22:13:12 2012 +0000
Commit: Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Wed Nov 21 21:25:21 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=8b1b3ed4
linux-user: fix emulation of getdents
In case when TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64, the last
byte of the target dirent structure (aka d_type byte) was never copied
from the host dirent structure, thus breaking everything that relies
on valid d_type value, e.g. glob(3).
Reviewed-by: Peter Maydell <peter.maydell <AT> linaro.org>
Signed-off-by: Dmitry V. Levin <ldv <AT> altlinux.org>
Signed-off-by: Riku Voipio <riku.voipio <AT> linaro.org>
(cherry picked from commit 333858b77c2b4f7636257808a77822c58bdd80fe)
---
linux-user/syscall.c | 11 +++++------
linux-user/syscall_defs.h | 8 ++++----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9bf0b28..6444155 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6959,15 +6959,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
tde = target_dirp;
while (len > 0) {
reclen = de->d_reclen;
- treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
+ tnamelen = reclen - offsetof(struct linux_dirent, d_name);
+ assert(tnamelen >= 0);
+ treclen = tnamelen + offsetof(struct target_dirent, d_name);
+ assert(count1 + treclen <= count);
tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapal(de->d_ino);
tde->d_off = tswapal(de->d_off);
- tnamelen = treclen - (2 * sizeof(abi_long) + 2);
- if (tnamelen > 256)
- tnamelen = 256;
- /* XXX: may not be correct */
- pstrcpy(tde->d_name, tnamelen, de->d_name);
+ memcpy(tde->d_name, de->d_name, tnamelen);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen);
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a79b67d..66814af 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -255,10 +255,10 @@ struct kernel_statfs {
};
struct target_dirent {
- abi_long d_ino;
- abi_long d_off;
- unsigned short d_reclen;
- char d_name[256]; /* We must not include limits.h! */
+ abi_long d_ino;
+ abi_long d_off;
+ unsigned short d_reclen;
+ char d_name[];
};
struct target_dirent64 {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-01-19 3:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-19 3:47 [gentoo-commits] proj/qemu-kvm:qemu-kvm-1.1.2-gentoo commit in: linux-user/ Doug Goldstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox