linux-user: Fix payload size logic in host_to_target_cmsg()
commit309786cfd8f701182eee845fd98e30fd5addd046
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 18 May 2018 18:47:15 +0000 (18 19:47 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 25 May 2018 08:10:55 +0000 (25 10:10 +0200)
tree387f9049e16a78acc3b5744e97343a46400304b4
parent2b5249b85cd9daaca3ea0a9ecab81c3e41cf9f55
linux-user: Fix payload size logic in host_to_target_cmsg()

Coverity points out that there's a missing break in the switch in
host_to_target_cmsg() where we update tgt_len for
cmsg_level/cmsg_type combinations which require a different length
for host and target (CID 1385425).  To avoid duplicating the default
case (target length same as host) in both switches, set that before
the switch so that only the cases which want to override it need any
code.

This fixes a bug where we would have used the wrong length
for SOL_SOCKET/SO_TIMESTAMP messages where the target and
host have differently sized 'struct timeval' (ie one is 32
bit and the other is 64 bit).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180518184715.29833-1-peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c