From 3c626a48251ae361ba9823145a6234841322e896 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 18 Dec 2015 10:15:10 +0100 Subject: Reduce the number of used syscalls by using sendmsg() instead of writev() We relied on sendmsg() anyway for the MSG_NO_SIGNAL version of the calls, thus it is a good idea to avoid calling writev() and use sendmsg(). That way we reduce the number of calls required for seccomp. --- lib/system.c | 9 +++++++-- tests/seccomp.c | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/system.c b/lib/system.c index aabe4c0fbc..f5f9c76ece 100644 --- a/lib/system.c +++ b/lib/system.c @@ -129,8 +129,13 @@ ssize_t system_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec, int iovec_cnt) { - return writev(GNUTLS_POINTER_TO_INT(ptr), (struct iovec *) iovec, - iovec_cnt); + struct msghdr hdr; + + memset(&hdr, 0, sizeof(hdr)); + hdr.msg_iov = (struct iovec *)iovec; + hdr.msg_iovlen = iovec_cnt; + + return sendmsg(GNUTLS_POINTER_TO_INT(ptr), &hdr, 0); } #endif diff --git a/tests/seccomp.c b/tests/seccomp.c index 557d71ac2d..8427fd9f7b 100644 --- a/tests/seccomp.c +++ b/tests/seccomp.c @@ -67,9 +67,6 @@ int disable_system_calls(void) ADD_SYSCALL(sendto, 0); ADD_SYSCALL(recvfrom, 0); - /* writev() is used explicitly */ - ADD_SYSCALL(writev, 0); - /* to read from /dev/urandom */ ADD_SYSCALL(read, 0); ADD_SYSCALL(getrandom, 0); -- cgit v1.2.1