From 651e65376c2f031d57f2fad3d9773b51f5916111 Mon Sep 17 00:00:00 2001 From: tobias <> Date: Thu, 26 Mar 2015 21:22:50 +0000 Subject: The code in socks.c writes multiple times in a row to a socket. If the socket becomes invalid between these calls (e.g. connection closed), write will throw SIGPIPE. With this patch, SIGPIPE is ignored so we can handle write's -1 return value (errno will be EPIPE). Ultimately, it leads to program exit, too -- but with nicer error message. :) with input by and ok djm --- src/usr.bin/nc/netcat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/usr.bin/nc/netcat.c') diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 88a2a25053..905ae4ea6d 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.128 2015/03/26 10:36:03 tobias Exp $ */ +/* $OpenBSD: netcat.c,v 1.129 2015/03/26 21:22:50 tobias Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -44,15 +44,16 @@ #include #include +#include +#include #include #include +#include #include #include #include #include #include -#include -#include #include "atomicio.h" #ifndef SUN_LEN @@ -141,6 +142,8 @@ main(int argc, char *argv[]) uport = NULL; sv = NULL; + signal(SIGPIPE, SIG_IGN); + while ((ch = getopt(argc, argv, "46DdFhI:i:klNnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) { switch (ch) { -- cgit v1.2.3-55-g6feb