summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobias <>2015-03-26 21:22:50 +0000
committertobias <>2015-03-26 21:22:50 +0000
commit651e65376c2f031d57f2fad3d9773b51f5916111 (patch)
tree4504310d787fa0dd30c300fd3739d99cdb9462bf
parent1654c26788ef33807b3d91c7aa1da8c6a30395a1 (diff)
downloadopenbsd-651e65376c2f031d57f2fad3d9773b51f5916111.tar.gz
openbsd-651e65376c2f031d57f2fad3d9773b51f5916111.tar.bz2
openbsd-651e65376c2f031d57f2fad3d9773b51f5916111.zip
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
Diffstat (limited to '')
-rw-r--r--src/usr.bin/nc/netcat.c9
1 files changed, 6 insertions, 3 deletions
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 @@
1/* $OpenBSD: netcat.c,v 1.128 2015/03/26 10:36:03 tobias Exp $ */ 1/* $OpenBSD: netcat.c,v 1.129 2015/03/26 21:22:50 tobias Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> 3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
4 * 4 *
@@ -44,15 +44,16 @@
44 44
45#include <err.h> 45#include <err.h>
46#include <errno.h> 46#include <errno.h>
47#include <fcntl.h>
48#include <limits.h>
47#include <netdb.h> 49#include <netdb.h>
48#include <poll.h> 50#include <poll.h>
51#include <signal.h>
49#include <stdarg.h> 52#include <stdarg.h>
50#include <stdio.h> 53#include <stdio.h>
51#include <stdlib.h> 54#include <stdlib.h>
52#include <string.h> 55#include <string.h>
53#include <unistd.h> 56#include <unistd.h>
54#include <fcntl.h>
55#include <limits.h>
56#include "atomicio.h" 57#include "atomicio.h"
57 58
58#ifndef SUN_LEN 59#ifndef SUN_LEN
@@ -141,6 +142,8 @@ main(int argc, char *argv[])
141 uport = NULL; 142 uport = NULL;
142 sv = NULL; 143 sv = NULL;
143 144
145 signal(SIGPIPE, SIG_IGN);
146
144 while ((ch = getopt(argc, argv, 147 while ((ch = getopt(argc, argv,
145 "46DdFhI:i:klNnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) { 148 "46DdFhI:i:klNnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
146 switch (ch) { 149 switch (ch) {