summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2013-04-03 19:38:20 +0000
committermatthew <matthew@openbsd.org>2013-04-03 19:38:20 +0000
commit162b37432cb2bb2596df62ee94a9a027db3443c9 (patch)
treeec6cab4f68604e787e7b23866ac31546fe945b35 /lib/libc
parentFix a typo in the bge_ape_lock_init() function. (diff)
downloadwireguard-openbsd-162b37432cb2bb2596df62ee94a9a027db3443c9.tar.xz
wireguard-openbsd-162b37432cb2bb2596df62ee94a9a027db3443c9.zip
Use MSG_NOSIGNAL when writing DNS queries over TCP sockets to ensure
we don't trigger SIGPIPE. ok millert
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/asr/res_send_async.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/asr/res_send_async.c b/lib/libc/asr/res_send_async.c
index 9f16aa4338b..e8457c26bc5 100644
--- a/lib/libc/asr/res_send_async.c
+++ b/lib/libc/asr/res_send_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send_async.c,v 1.13 2013/04/02 21:57:33 eric Exp $ */
+/* $OpenBSD: res_send_async.c,v 1.14 2013/04/03 19:38:20 matthew Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -516,6 +516,7 @@ udp_recv(struct async *as)
static int
tcp_write(struct async *as)
{
+ struct msghdr msg;
struct iovec iov[2];
uint16_t len;
ssize_t n;
@@ -552,7 +553,11 @@ tcp_write(struct async *as)
iov[i].iov_len = as->as.dns.obuflen - offset;
i++;
- n = writev(as->as_fd, iov, i);
+ memset(&msg, 0, sizeof msg);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = i;
+
+ n = sendmsg(as->as_fd, &msg, MSG_NOSIGNAL);
if (n == -1)
goto close; /* errno set */