Check for errors on write. Since SIGPIPE is ignored, play nicely with
pipelines by aborting on EPIPE.
---
 src/apps/s_server.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/apps/s_server.c b/src/apps/s_server.c
index 77384ec..836d46b 100644
--- a/src/apps/s_server.c
+++ b/src/apps/s_server.c
@@ -1760,8 +1760,11 @@ sv_body(char *hostname, int s, unsigned char *context)
                                i = SSL_read(con, (char *) buf, bufsize);
                                switch (SSL_get_error(con, i)) {
                                case SSL_ERROR_NONE:
-                                       write(fileno(stdout), buf,
-                                           (unsigned int) i);
+                                       if (write(fileno(stdout), buf, i) == 
-1) {
+                                               if (errno == EPIPE) {
+                                                       abort();
+                                               }
+                                       }
                                        if (SSL_pending(con))
                                                goto again;
                                        break;
-- 
1.9.3

Reply via email to