From 5550f2f5aeb8f9f1aa3af8159cffda6e7c6d38a2 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 15 Sep 2019 17:17:51 +0100 Subject: Set the MSG_NOSIGNAL flag send send()ing so a bad socket write doesn't terminate blabouncer with SIGPIPE. --- sockets.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 } } -- cgit v1.2.3