diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-12-18 10:15:10 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-12-18 10:15:41 +0100 |
commit | 3c626a48251ae361ba9823145a6234841322e896 (patch) | |
tree | 11eaa2f458b3fc58405349554d33c03d92a7ef12 | |
parent | d0899dbc4344d84a71a3901c489624439fdbe15a (diff) | |
download | gnutls-3c626a48251ae361ba9823145a6234841322e896.tar.gz |
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.
-rw-r--r-- | lib/system.c | 9 | ||||
-rw-r--r-- | 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); |