summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc
diff options
context:
space:
mode:
authortb <>2022-12-18 12:53:18 +0000
committertb <>2022-12-18 12:53:18 +0000
commit9120cbac04bd757c024a3d0a0cfbaf9ce8e79e96 (patch)
treee84216b90e21632bf57fc58964769a657902e5e9 /src/usr.bin/nc
parentf6c5727ba2ff8f1e107e721f591c0068711c57fa (diff)
downloadopenbsd-9120cbac04bd757c024a3d0a0cfbaf9ce8e79e96.tar.gz
openbsd-9120cbac04bd757c024a3d0a0cfbaf9ce8e79e96.tar.bz2
openbsd-9120cbac04bd757c024a3d0a0cfbaf9ce8e79e96.zip
nc: skip connection info on failed or skipped udptest()
In udp mode, nc would always print that the connected succeeded independently of whether that was actually the case. Don't do that. idea/ok mpf
Diffstat (limited to 'src/usr.bin/nc')
-rw-r--r--src/usr.bin/nc/netcat.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index dc60158749..3ee1670053 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.223 2022/12/18 12:51:10 tb Exp $ */ 1/* $OpenBSD: netcat.c,v 1.224 2022/12/18 12:53:18 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.
@@ -700,16 +700,19 @@ main(int argc, char *argv[])
700 700
701 ret = 0; 701 ret = 0;
702 if (vflag || zflag) { 702 if (vflag || zflag) {
703 int print_info = 1;
704
703 /* For UDP, make sure we are connected. */ 705 /* For UDP, make sure we are connected. */
704 if (uflag) { 706 if (uflag) {
705 if (udptest(s) == -1) { 707 /* No info on failed or skipped test. */
708 if ((print_info = udptest(s)) == -1) {
706 ret = 1; 709 ret = 1;
707 continue; 710 continue;
708 } 711 }
709 } 712 }
710 713 if (print_info == 1)
711 connection_info(host, portlist[i], 714 connection_info(host, portlist[i],
712 uflag ? "udp" : "tcp", ipaddr); 715 uflag ? "udp" : "tcp", ipaddr);
713 } 716 }
714 if (Fflag) 717 if (Fflag)
715 fdpass(s); 718 fdpass(s);