linux-user: Avoid possible misalignment in host_to_target_siginfo()
commit55d72a7eb32858d50ba0777cfde2027d007010b2
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 13 Jun 2016 10:22:05 +0000 (13 11:22 +0100)
committerRiku Voipio <riku.voipio@linaro.org>
Fri, 24 Jun 2016 08:55:44 +0000 (24 11:55 +0300)
treeaee8282bced8d478e2315c800e1bff4c5e215bf9
parentc7288767523f6510cf557707d3eb5e78e519b90d
linux-user: Avoid possible misalignment in host_to_target_siginfo()

host_to_target_siginfo() is implemented by a combination of
host_to_target_siginfo_noswap() followed by tswap_siginfo().
The first of these two functions assumes that the target_siginfo_t
it is writing to is correctly aligned, but the pointer passed
into host_to_target_siginfo() is directly from the guest and
might be misaligned. Use a local variable to avoid this problem.
(tswap_siginfo() does now correctly handle a misaligned destination.)

We have to add a memset() to host_to_target_siginfo_noswap()
to avoid some false positive "may be used uninitialized" warnings
from gcc about subfields of the _sifields union if it chooses to
inline both tswap_siginfo() and host_to_target_siginfo_noswap()
into host_to_target_siginfo().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Peter Maydell <riku.voipio@linaro.org>
linux-user/signal.c