[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 31/60] linux-user: fix emulation of getdents
From: |
Michael Tokarev |
Subject: |
[Qemu-stable] [PATCH 31/60] linux-user: fix emulation of getdents |
Date: |
Mon, 4 Feb 2013 14:40:41 +0400 |
From: "Dmitry V. Levin" <address@hidden>
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 <address@hidden>
Signed-off-by: Dmitry V. Levin <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
(cherry picked from commit 333858b77c2b4f7636257808a77822c58bdd80fe)
Signed-off-by: Michael Tokarev <address@hidden>
---
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 {
--
1.7.10.4
- [Qemu-stable] [PATCH 13/60] usb-audio: fix usb version, (continued)
- [Qemu-stable] [PATCH 13/60] usb-audio: fix usb version, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 37/60] target-sparc64: disable VGA cirrus, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 14/60] fpu/softfloat.c: Return correctly signed values from uint64_to_float32, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 52/60] uhci: Don't queue up packets after one with the SPD flag set, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 08/60] eepro100: Fix network hang when rx buffers run out, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 53/60] hw/qxl: qxl_send_events: nop if stopped, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 12/60] intel_hda: do not call msi_reset when only device state needs resetting, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 24/60] qxl: always update displaysurface on resize, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 36/60] PPC: Bamboo: Fix memory size DT property, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 17/60] net: notify iothread after flushing queue, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 31/60] linux-user: fix emulation of getdents,
Michael Tokarev <=
- [Qemu-stable] [PATCH 44/60] qcow2: Fix refcount table size calculation, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 43/60] qcow2: Fix avail_sectors in cluster allocation code, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 06/60] fix doc of using raw values with sendkey, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 48/60] ide: Fix crash with too long PRD, Michael Tokarev, 2013/02/04
- Re: [Qemu-stable] Patch queue for qemu-1.1.3 stable release, Doug Goldstein, 2013/02/04
- Re: [Qemu-stable] [Qemu-devel] Patch queue for qemu-1.1.3 stable release, Michael Tokarev, 2013/02/19