Stuart Henderson wrote:
> But I can't imagine scanning a range by name as being much used
> (tcpmux-socks or something just doesn't make sense).
>
> What I think would be least disruptive is to continue to allow - where
> the rest of the parameter is numeric. For alphabetic parameters try
> parsing the whole word as a service; use it if valid. If not,
> *either* it could just error out (simple and unambiguous) *or* it
> could try parsing as a named range. But I don't think you will hurt
> anyone by just erroring out in that case.
This is my attempt at that.
Index: nc.1
===================================================================
RCS file: /cvs/src/usr.bin/nc/nc.1,v
retrieving revision 1.91
diff -u -p -r1.91 nc.1
--- nc.1 25 Sep 2018 20:05:07 -0000 1.91
+++ nc.1 23 Dec 2018 00:25:43 -0000
@@ -391,8 +391,8 @@ sockets, a destination is required and i
option is given).
.Pp
.Ar port
-can be a specified as a numeric port number, or as a service name.
-Ports may be specified in a range of the form
+can be a specified as a numeric port number or as a service name.
+Port ranges may be specified as numeric port numbers of the form
.Ar nn Ns - Ns Ar mm .
In general,
a destination port must be specified,
Index: netcat.c
===================================================================
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.199
diff -u -p -r1.199 netcat.c
--- netcat.c 29 Nov 2018 14:25:06 -0000 1.199
+++ netcat.c 23 Dec 2018 00:27:00 -0000
@@ -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++;