qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: fix undefined shift in copy_to_user_fdset
@ 2013-04-09 11:02 Andreas Schwab
  2013-04-09 11:12 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2013-04-09 11:02 UTC (permalink / raw)
  To: qemu-devel

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>
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fa3039f..5abc16f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -922,7 +922,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]);
-- 
1.8.2.1

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: fix undefined shift in copy_to_user_fdset
  2013-04-09 11:02 [Qemu-devel] [PATCH] linux-user: fix undefined shift in copy_to_user_fdset Andreas Schwab
@ 2013-04-09 11:12 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2013-04-09 11:12 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Riku Voipio, qemu-devel

On 9 April 2013 12:02, Andreas Schwab <schwab@suse.de> wrote:
> 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>

-- PMM

> ---
>  linux-user/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index fa3039f..5abc16f 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -922,7 +922,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]);
> --
> 1.8.2.1
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-09 11:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 11:02 [Qemu-devel] [PATCH] linux-user: fix undefined shift in copy_to_user_fdset Andreas Schwab
2013-04-09 11:12 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).