qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault


From: Alexander Graf
Subject: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault
Date: Sun, 20 Nov 2011 13:06:26 +0100

While debugging some issues with QEMU_STRACE I stumbled over segmentation
faults that were pretty reproducible. Turns out we tried to treat a
normal return value as errno, resulting in an access over array boundaries
for the resolution.

Fix this by hard-mapping values above valid errnos to the original value.

Signed-off-by: Alexander Graf <address@hidden>
---
 linux-user/syscall.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f227097..312aec5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,9 @@ static inline int host_to_target_errno(int err)
 
 static inline int target_to_host_errno(int err)
 {
+    if (err >= ERRNO_TABLE_SIZE) {
+        return err;
+    }
     if (target_to_host_errno_table[err])
         return target_to_host_errno_table[err];
     return err;
-- 
1.6.0.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]