Re: [Qemu-devel] [PATCH] linux-user/syscall.c: fix copy_to_user_fdset for fds over 30

2013-01-04 Thread Richard Henderson
On 01/03/2013 02:02 AM, Nickolai Zeldovich wrote: -v |= ((FD_ISSET(k, fds) != 0) j); +v |= (((abi_ulong) (FD_ISSET(k, fds) != 0)) j); It would be easier to read if you dropped the unnecessary parens. v |= (abi_ulong)(FD_ISSET(k, fds) != 0) j; Otherwise the

[Qemu-devel] [PATCH] linux-user/syscall.c: fix copy_to_user_fdset for fds over 30

2013-01-03 Thread Nickolai Zeldovich
On a 64-bit system (e.g., x86_64), copy_to_user_fdset populates the bitmask returned to the user-space program by left-shifting the value (FD_ISSET(k, fds) != 0), which is of type int, by k bits (0 through 63). According to the C standard, left-shifting an int by 31 bits is undefined behavior