linux-user: fix signal number range check

Submitted by Andreas Schwab on June 15, 2013, 12:33 p.m.

Details

Message ID 878v2b8sek.fsf@igel.home
State New
Headers show

Commit Message

Andreas Schwab June 15, 2013, 12:33 p.m.
When translating between host and target signal numbers keep negative
numbers unchanged, avoiding access beyond array bounds.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 linux-user/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell June 15, 2013, 3:13 p.m.
On 15 June 2013 13:33, Andreas Schwab <schwab@linux-m68k.org> wrote:
> When translating between host and target signal numbers keep negative
> numbers unchanged, avoiding access beyond array bounds.
>
> Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

Patch hide | download patch | download mbox

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 5da8452..c4d8970 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -102,14 +102,14 @@  static inline int sas_ss_flags(unsigned long sp)
 
 int host_to_target_signal(int sig)
 {
-    if (sig >= _NSIG)
+    if (sig < 0 || sig >= _NSIG)
         return sig;
     return host_to_target_signal_table[sig];
 }
 
 int target_to_host_signal(int sig)
 {
-    if (sig >= _NSIG)
+    if (sig < 0 || sig >= _NSIG)
         return sig;
     return target_to_host_signal_table[sig];
 }