aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJing Huang <jing.huang.pku@gmail.com>2012-07-24 13:58:02 +0000
committerPeter Maydell <peter.maydell@linaro.org>2012-08-13 12:47:09 +0100
commitb870367485eb4f1d096ddc00f011d56f1cd74e6e (patch)
tree573aa976944ece153e0220c9664a9f1d4f1e4704
parent34aa33eea21482e59e6c7b6ab855fe018c6b1493 (diff)
downloadqemu-arm-b870367485eb4f1d096ddc00f011d56f1cd74e6e.tar.gz
linux-user: pass sockaddr from host to target
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--linux-user/syscall.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1af68d2821..47f0eb3729 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1268,7 +1268,6 @@ static inline abi_long host_to_target_sockaddr(abi_ulong target_addr,
return 0;
}
-/* ??? Should this also swap msgh->name? */
static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
struct target_msghdr *target_msgh)
{
@@ -1325,7 +1324,6 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh,
return 0;
}
-/* ??? Should this also swap msgh->name? */
static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
struct msghdr *msgh)
{
@@ -1885,10 +1883,22 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
if (!is_error(ret)) {
len = ret;
ret = host_to_target_cmsg(msgp, &msg);
- if (!is_error(ret))
+ if (!is_error(ret)) {
+ msgp->msg_namelen = tswap32(msg.msg_namelen);
+ if (msg.msg_name != NULL) {
+ ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
+ msg.msg_name, msg.msg_namelen);
+ if (ret) {
+ goto out;
+ }
+ }
+
ret = len;
+ }
}
}
+
+out:
unlock_iovec(vec, target_vec, count, !send);
unlock_user_struct(msgp, target_msg, send ? 0 : 1);
return ret;