aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-05-31 17:33:35 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-06-06 17:21:27 +0100
commit88072de52c58a392b95afea1fa426ff8183b0b14 (patch)
treebb432a87581ece2aaf565e865203f810c262b0b8
parent1fe354b9888f1a5b257ebe861375292a98bbd314 (diff)
downloadqemu-arm-88072de52c58a392b95afea1fa426ff8183b0b14.tar.gz
linux-user: Use safe_syscall wrapper for send* and recv* syscalls
Use the safe_syscall wrapper for the send, sendto, sendmsg, recv, recvfrom and recvmsg syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--linux-user/syscall.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b649a8c7fe..f5c547667e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -703,6 +703,12 @@ safe_syscall3(ssize_t, readv, int, fd, const struct iovec *, iov, int, iovcnt)
safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt)
safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr,
socklen_t, addrlen)
+safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len,
+ int, flags, const struct sockaddr *, addr, socklen_t, addrlen)
+safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf, size_t, len,
+ int, flags, struct sockaddr *, addr, socklen_t *, addrlen)
+safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int, flags)
+safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags)
static inline int host_to_target_sock_type(int host_type)
{
@@ -2282,9 +2288,9 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
if (send) {
ret = target_to_host_cmsg(&msg, msgp);
if (ret == 0)
- ret = get_errno(sendmsg(fd, &msg, flags));
+ ret = get_errno(safe_sendmsg(fd, &msg, flags));
} else {
- ret = get_errno(recvmsg(fd, &msg, flags));
+ ret = get_errno(safe_recvmsg(fd, &msg, flags));
if (!is_error(ret)) {
len = ret;
ret = host_to_target_cmsg(msgp, &msg);
@@ -2521,9 +2527,9 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
unlock_user(host_msg, msg, 0);
return ret;
}
- ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen));
+ ret = get_errno(safe_sendto(fd, host_msg, len, flags, addr, addrlen));
} else {
- ret = get_errno(send(fd, host_msg, len, flags));
+ ret = get_errno(safe_sendto(fd, host_msg, len, flags, NULL, 0));
}
unlock_user(host_msg, msg, 0);
return ret;
@@ -2552,10 +2558,11 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
goto fail;
}
addr = alloca(addrlen);
- ret = get_errno(recvfrom(fd, host_msg, len, flags, addr, &addrlen));
+ ret = get_errno(safe_recvfrom(fd, host_msg, len, flags,
+ addr, &addrlen));
} else {
addr = NULL; /* To keep compiler quiet. */
- ret = get_errno(qemu_recv(fd, host_msg, len, flags));
+ ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, NULL, 0));
}
if (!is_error(ret)) {
if (target_addr) {