Patchwork [2/3] linux-user: fix undefined shift in copy_to_user_fdset

login
register
mail settings
Submitter riku.voipio@linaro.org
Date April 19, 2013, 1:59 p.m.
Message ID <9ab709be595bef9956ea550a95e14e157cb5704e.1366377671.git.riku.voipio@linaro.org>
Download mbox | patch
Permalink /patch/237965/
State New
Headers show

Comments

riku.voipio@linaro.org - April 19, 2013, 1:59 p.m.
From: Andreas Schwab <schwab@suse.de>

If TARGET_ABI_BITS is bigger than 32 we shift by more than the size of int.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d6d2050..5a786f2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -914,7 +914,7 @@  static inline abi_long copy_to_user_fdset(abi_ulong target_fds_addr,
     for (i = 0; i < nw; i++) {
         v = 0;
         for (j = 0; j < TARGET_ABI_BITS; j++) {
-            v |= ((FD_ISSET(k, fds) != 0) << j);
+            v |= ((abi_ulong)(FD_ISSET(k, fds) != 0) << j);
             k++;
         }
         __put_user(v, &target_fds[i]);