diff options
Diffstat (limited to 'sys/compat/cloudabi64/cloudabi64_sock.c')
-rw-r--r-- | sys/compat/cloudabi64/cloudabi64_sock.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c index e6b9c94..3915ddf 100644 --- a/sys/compat/cloudabi64/cloudabi64_sock.c +++ b/sys/compat/cloudabi64/cloudabi64_sock.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <compat/cloudabi/cloudabi_util.h> #include <compat/cloudabi64/cloudabi64_proto.h> +#include <compat/cloudabi64/cloudabi64_util.h> static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket"); @@ -52,6 +53,7 @@ cloudabi64_sys_sock_recv(struct thread *td, cloudabi64_recv_out_t ro = {}; cloudabi64_iovec_t iovobj; struct msghdr msghdr = {}; + const cloudabi64_iovec_t *user_iov; size_t i; int error; @@ -65,14 +67,14 @@ cloudabi64_sys_sock_recv(struct thread *td, msghdr.msg_iovlen = ri.ri_datalen; msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), M_SOCKET, M_WAITOK); + user_iov = TO_PTR(ri.ri_data); for (i = 0; i < msghdr.msg_iovlen; i++) { - error = copyin(&((cloudabi64_iovec_t *)ri.ri_data)[i], &iovobj, - sizeof(iovobj)); + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { free(msghdr.msg_iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base; + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); msghdr.msg_iov[i].iov_len = iovobj.iov_len; } msghdr.msg_name = &ss; @@ -104,6 +106,7 @@ cloudabi64_sys_sock_send(struct thread *td, cloudabi64_send_out_t so = {}; cloudabi64_ciovec_t iovobj; struct msghdr msghdr = {}; + const cloudabi64_ciovec_t *user_iov; size_t i; int error, flags; @@ -117,14 +120,14 @@ cloudabi64_sys_sock_send(struct thread *td, msghdr.msg_iovlen = si.si_datalen; msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), M_SOCKET, M_WAITOK); + user_iov = TO_PTR(si.si_data); for (i = 0; i < msghdr.msg_iovlen; i++) { - error = copyin(&((cloudabi64_ciovec_t *)si.si_data)[i], &iovobj, - sizeof(iovobj)); + error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { free(msghdr.msg_iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base; + msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); msghdr.msg_iov[i].iov_len = iovobj.iov_len; } |