From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SthU2-0002v7-Ly for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:57:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SthTu-0006ce-Tu for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:57:14 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:36377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SthTu-0006cY-Pc for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:57:06 -0400 Received: by yenl1 with SMTP id l1so6930831yen.4 for ; Tue, 24 Jul 2012 08:57:06 -0700 (PDT) From: Jing Huang Date: Tue, 24 Jul 2012 23:58:02 +0000 Message-Id: <1343174282-10291-1-git-send-email-jing.huang.pku@gmail.com> In-Reply-To: References: Subject: [Qemu-devel] [PATCH V6 1/3] linux-user: pass sockaddr from host to target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, riku.voipio@iki.fi Signed-off-by: Jing Huang Reviewed-by: Peter Maydell --- linux-user/syscall.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 539af3f..6385934 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1256,7 +1256,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) { @@ -1313,7 +1312,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) { @@ -1873,10 +1871,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; -- 1.7.8.6