diff options
-rw-r--r-- | arch/x86_64/bits/socket.h | 4 | ||||
-rw-r--r-- | src/network/recvmsg.c | 12 | ||||
-rw-r--r-- | src/network/sendmsg.c | 9 |
3 files changed, 23 insertions, 2 deletions
diff --git a/arch/x86_64/bits/socket.h b/arch/x86_64/bits/socket.h index b3230625..0e5ee1aa 100644 --- a/arch/x86_64/bits/socket.h +++ b/arch/x86_64/bits/socket.h @@ -3,9 +3,9 @@ struct msghdr void *msg_name; socklen_t msg_namelen; struct iovec *msg_iov; - int msg_iovlen; + int msg_iovlen, __pad1; void *msg_control; - socklen_t msg_controllen; + socklen_t msg_controllen, __pad2; int msg_flags; }; diff --git a/src/network/recvmsg.c b/src/network/recvmsg.c index edc5f241..65094fc8 100644 --- a/src/network/recvmsg.c +++ b/src/network/recvmsg.c @@ -1,12 +1,24 @@ #include <sys/socket.h> +#include <limits.h> #include "syscall.h" #include "libc.h" ssize_t recvmsg(int fd, struct msghdr *msg, int flags) { ssize_t r; +#if LONG_MAX > INT_MAX + struct msghdr h, *orig = msg; + if (msg) { + h = *msg; + h.__pad1 = h.__pad2 = 0; + msg = &h; + } +#endif CANCELPT_BEGIN; r = socketcall(recvmsg, fd, msg, flags, 0, 0, 0); CANCELPT_END; +#if LONG_MAX > INT_MAX + if (orig) *orig = h; +#endif return r; } diff --git a/src/network/sendmsg.c b/src/network/sendmsg.c index 5d1123f0..047c0eff 100644 --- a/src/network/sendmsg.c +++ b/src/network/sendmsg.c @@ -1,10 +1,19 @@ #include <sys/socket.h> +#include <limits.h> #include "syscall.h" #include "libc.h" ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) { ssize_t r; +#if LONG_MAX > INT_MAX + struct msghdr h; + if (msg) { + h = *msg; + h.__pad1 = h.__pad2 = 0; + msg = &h; + } +#endif CANCELPT_BEGIN; r = socketcall(sendmsg, fd, msg, flags, 0, 0, 0); CANCELPT_END; |