summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-12-18 12:51:10 +0000
committertb <>2022-12-18 12:51:10 +0000
commitf6c5727ba2ff8f1e107e721f591c0068711c57fa (patch)
tree5adcb5bdca57190654547b6a9004d29dfbed011a /src
parent67734fde6d4ddc6852e156e05415b7bb6ded06da (diff)
downloadopenbsd-f6c5727ba2ff8f1e107e721f591c0068711c57fa.tar.gz
openbsd-f6c5727ba2ff8f1e107e721f591c0068711c57fa.tar.bz2
openbsd-f6c5727ba2ff8f1e107e721f591c0068711c57fa.zip
nc: do not test the connection in non-interactive mode
The connection test writes four X to the socket, which corrupts data that we may want to pipe into nc. So don't do that if stdin is not a tty but still do it in scan mode, this is needed according to chris. based on a diff by and ok mpf
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/nc/netcat.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index e945ba6e8f..dc60158749 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.222 2022/12/18 12:48:28 tb Exp $ */ 1/* $OpenBSD: netcat.c,v 1.223 2022/12/18 12:51:10 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> 3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
4 * Copyright (c) 2015 Bob Beck. All rights reserved. 4 * Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -1510,6 +1510,10 @@ udptest(int s)
1510{ 1510{
1511 int i, ret; 1511 int i, ret;
1512 1512
1513 /* Only write to the socket in scan mode or interactive mode. */
1514 if (!zflag && !isatty(STDIN_FILENO))
1515 return 0;
1516
1513 for (i = 0; i <= 3; i++) { 1517 for (i = 0; i <= 3; i++) {
1514 if (write(s, "X", 1) == 1) 1518 if (write(s, "X", 1) == 1)
1515 ret = 1; 1519 ret = 1;