summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2013-04-03 19:38:21 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2013-04-03 19:38:21 +0000
commit2242e7212f8ad589e0917bd6c82e52df96be126b (patch)
treee3a177293a36d2871af4cf874a8d7c24b3f44240 /lib/libc
parenta8e583250be6a24fa75a5f8c04928c58356f91a6 (diff)
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 */