aboutsummaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-06-06 19:58:04 +0100
committerRiku Voipio <riku.voipio@linaro.org>2016-06-08 10:13:45 +0300
commit666875306e03e1f94e1d4c808502585c10abc69a (patch)
tree46f90c7eae8a10626ea3f10eb349f043301c5779 /linux-user/syscall.c
parent2a3c7619288af9cfcc09a233dce911bf80849dfb (diff)
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. RV: adjusted to apply Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-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 b363944e74..bcae62d068 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -716,6 +716,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)
{
@@ -2910,10 +2916,10 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
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;
if (fd_trans_host_to_target_data(fd)) {
@@ -3162,9 +3168,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;
@@ -3193,10 +3199,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) {