Skip to content

Commit

Permalink
linux-user: pass sockaddr from host to target
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jinghuang authored and pm215 committed Aug 14, 2012
1 parent dd6e957 commit ca61906
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions linux-user/syscall.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca61906

Please sign in to comment.