summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-15 17:17:51 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-15 17:17:51 +0100
commit5550f2f5aeb8f9f1aa3af8159cffda6e7c6d38a2 (patch)
treeec5810c06a7c669c6ddd58e818e709ec8e75d982
parentaab7a7000cff14afe4cb331721ad55dc139f80c7 (diff)
Set the MSG_NOSIGNAL flag send send()ing so a bad socket write doesn't terminate blabouncer with SIGPIPE.
-rw-r--r--sockets.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sockets.c b/sockets.c
index 64a3e5d..5b4c0c2 100644
--- a/sockets.c
+++ b/sockets.c
@@ -223,8 +223,10 @@ int socksend(SSL *fd, char *buf, int bufsize, int tls) {
if (tls) {
return SSL_write(fd, buf, bufsize);
} else {
+ // Clear errno in case send() errors
+ errno = 0;
// Cast the supposed SSL *fd to a long int if we're not using TLS
- return send((long int)fd, buf, bufsize, 0);
+ return send((long int)fd, buf, bufsize, MSG_NOSIGNAL); // MSG_NOSIGNAL so a bad send() can't SIGPIPE blabouncer
}
}