diff mbox

[12/16,RFC] linux-user: fix sigismember() check

Message ID 1494586944-7253-13-git-send-email-Milos.Stojanovic@rt-rk.com
State New
Headers show

Commit Message

Milos Stojanovic May 12, 2017, 11:02 a.m. UTC
Fix copying between the host and target signal sets for the case when the
target set is larger than the host set.

sigismember() returns 1 if the specified signal number is a member of
the specified signal set, but it can also return -1 if an error occurs
(e.g. an out of range signal number is specified). All non-zero values
would cause the signal to be added, so a comparison with 1 is added to
assure that only the signals which are really in the set get added to
the other set.

Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
---
 linux-user/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 59d70ec..d72caaf 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -149,7 +149,7 @@  static void host_to_target_sigset_internal(target_sigset_t *d,
     int i;
     target_sigemptyset(d);
     for (i = 1; i <= TARGET_NSIG; i++) {
-        if (sigismember(s, i)) {
+        if (sigismember(s, i) == 1) {
             target_sigaddset(d, host_to_target_signal(i));
         }
     }
@@ -171,7 +171,7 @@  static void target_to_host_sigset_internal(sigset_t *d,
     int i;
     sigemptyset(d);
     for (i = 1; i <= TARGET_NSIG; i++) {
-        if (target_sigismember(s, i)) {
+        if (target_sigismember(s, i) == 1) {
             sigaddset(d, target_to_host_signal(i));
         }
     }