summaryrefslogtreecommitdiff
path: root/usr.bin/nc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-11-17 17:38:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-11-17 17:38:34 +0000
commitbae0a805ee2da41a86eea4f71514722bc55884b5 (patch)
tree3d6bc4e2251d0b817eec39eb97a9ab394c82af50 /usr.bin/nc
parent1a9ef7e80acbe5dc8e9b18365db17c530ffae2e3 (diff)
fail to usage if extra argv are present
noticed by jsing and beck, ok tedu
Diffstat (limited to 'usr.bin/nc')
-rw-r--r--usr.bin/nc/netcat.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index 1dc95e9f360..051daf18118 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.211 2019/11/13 04:10:38 beck Exp $ */
+/* $OpenBSD: netcat.c,v 1.212 2019/11/17 17:38:33 deraadt Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
* Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -352,15 +352,11 @@ main(int argc, char *argv[])
err(1, "setrtable");
/* Cruft to make sure options are clean, and used properly. */
- if (argv[0] && !argv[1] && family == AF_UNIX) {
+ if (argc == 1 && family == AF_UNIX) {
host = argv[0];
- uport = NULL;
- } else if (argv[0] && !argv[1]) {
- if (!lflag)
- usage(1);
+ } else if (argc == 1 && lflag) {
uport = argv[0];
- host = NULL;
- } else if (argv[0] && argv[1]) {
+ } else if (argc == 2) {
host = argv[0];
uport = argv[1];
} else