summaryrefslogtreecommitdiff
path: root/usr.bin/nc/netcat.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2018-12-27 17:22:46 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2018-12-27 17:22:46 +0000
commite4fe8ad0eb28497fd0b34733f444ae45bb30bc67 (patch)
treee0a976ccb35221fba7dc64ec6cabd07231969f0f /usr.bin/nc/netcat.c
parenta813b3fbddfe5fd6dfae56f506426dbc23d26de0 (diff)
port ranges can be ambiguous with hypenated port-names.
specify that ranges must be numeric, and only check for range if first argument is a digit. identified by danj, fix suggest by sthen
Diffstat (limited to 'usr.bin/nc/netcat.c')
-rw-r--r--usr.bin/nc/netcat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index e0966f1952d..adfad2dcd91 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.199 2018/11/29 14:25:06 tedu Exp $ */
+/* $OpenBSD: netcat.c,v 1.200 2018/12/27 17:22:45 tedu Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
* Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -42,6 +42,7 @@
#include <netinet/ip.h>
#include <arpa/telnet.h>
+#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
@@ -1427,7 +1428,7 @@ build_ports(char *p)
int hi, lo, cp;
int x = 0;
- if ((n = strchr(p, '-')) != NULL) {
+ if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) {
*n = '\0';
n++;