aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorPetar Jovanovic <petar.jovanovic@imgtec.com>2013-09-13 19:27:29 +0200
committerRiku Voipio <riku.voipio@linaro.org>2013-09-24 10:47:07 +0300
commitdbf4f7965af974593da596ec12ac877d248efed6 (patch)
treee1eb710c1d2bf05bd3fe6be3e9eb7d11697e722f /linux-user
parent03cfd8faa7ffb7201e2949b99c2f35b1fef7078b (diff)
downloadqemu-dbf4f7965af974593da596ec12ac877d248efed6.zip
qemu-dbf4f7965af974593da596ec12ac877d248efed6.tar.gz
qemu-dbf4f7965af974593da596ec12ac877d248efed6.tar.bz2
linux-user: correct how SOL_SOCKET is converted from target to host and back
Previous implementation does not take into account that SOL_SOCKET constant can be arch specific. This change fixes some issues with sendmsg/recvmsg. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7a093ba..aebe36d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1150,11 +1150,15 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
break;
}
- cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level);
+ if (tswap32(target_cmsg->cmsg_level) == TARGET_SOL_SOCKET) {
+ cmsg->cmsg_level = SOL_SOCKET;
+ } else {
+ cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level);
+ }
cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type);
cmsg->cmsg_len = CMSG_LEN(len);
- if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
+ if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type);
memcpy(data, target_data, len);
} else {
@@ -1205,11 +1209,15 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
break;
}
- target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
+ if (cmsg->cmsg_level == SOL_SOCKET) {
+ target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET);
+ } else {
+ target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level);
+ }
target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type);
target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len));
- if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) &&
+ if ((cmsg->cmsg_level == SOL_SOCKET) &&
(cmsg->cmsg_type == SCM_RIGHTS)) {
int *fd = (int *)data;
int *target_fd = (int *)target_data;
@@ -1217,7 +1225,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
for (i = 0; i < numfds; i++)
target_fd[i] = tswap32(fd[i]);
- } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) &&
+ } else if ((cmsg->cmsg_level == SOL_SOCKET) &&
(cmsg->cmsg_type == SO_TIMESTAMP) &&
(len == sizeof(struct timeval))) {
/* copy struct timeval to target */