diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-18 12:53:19 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-18 12:53:19 +0000 |
commit | aa929fbcda9fb246c2595afb35de8a1c6096ad61 (patch) | |
tree | 48ef5cb86f1ed7f851d16f2b25c1d9ea075fe472 | |
parent | 9abea089aec1f5b13722880c3a0ec8bea087c1db (diff) |
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
-rw-r--r-- | usr.bin/nc/netcat.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index dc60158749b..3ee1670053d 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.223 2022/12/18 12:51:10 tb Exp $ */ +/* $OpenBSD: netcat.c,v 1.224 2022/12/18 12:53:18 tb Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * Copyright (c) 2015 Bob Beck. All rights reserved. @@ -700,16 +700,19 @@ main(int argc, char *argv[]) ret = 0; if (vflag || zflag) { + int print_info = 1; + /* For UDP, make sure we are connected. */ if (uflag) { - if (udptest(s) == -1) { + /* No info on failed or skipped test. */ + if ((print_info = udptest(s)) == -1) { ret = 1; continue; } } - - connection_info(host, portlist[i], - uflag ? "udp" : "tcp", ipaddr); + if (print_info == 1) + connection_info(host, portlist[i], + uflag ? "udp" : "tcp", ipaddr); } if (Fflag) fdpass(s); |