diff options
author | tedu <> | 2018-12-27 17:22:45 +0000 |
---|---|---|
committer | tedu <> | 2018-12-27 17:22:45 +0000 |
commit | b9643eff963a290c90472e3405d942eaa3e1f2ca (patch) | |
tree | 73d34fb5c2408c50eebaf03df59512c779515402 /src | |
parent | 9641c932f4cf7d975c8a05c0ce14f13304cb4791 (diff) | |
download | openbsd-b9643eff963a290c90472e3405d942eaa3e1f2ca.tar.gz openbsd-b9643eff963a290c90472e3405d942eaa3e1f2ca.tar.bz2 openbsd-b9643eff963a290c90472e3405d942eaa3e1f2ca.zip |
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 'src')
-rw-r--r-- | src/usr.bin/nc/nc.1 | 8 | ||||
-rw-r--r-- | src/usr.bin/nc/netcat.c | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1 index 2c84a0972f..b05575df67 100644 --- a/src/usr.bin/nc/nc.1 +++ b/src/usr.bin/nc/nc.1 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: nc.1,v 1.91 2018/09/25 20:05:07 jmc Exp $ | 1 | .\" $OpenBSD: nc.1,v 1.92 2018/12/27 17:22:45 tedu Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 1996 David Sacerdote | 3 | .\" Copyright (c) 1996 David Sacerdote |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. |
@@ -25,7 +25,7 @@ | |||
25 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | .\" | 27 | .\" |
28 | .Dd $Mdocdate: September 25 2018 $ | 28 | .Dd $Mdocdate: December 27 2018 $ |
29 | .Dt NC 1 | 29 | .Dt NC 1 |
30 | .Os | 30 | .Os |
31 | .Sh NAME | 31 | .Sh NAME |
@@ -391,8 +391,8 @@ sockets, a destination is required and is the socket path to connect to | |||
391 | option is given). | 391 | option is given). |
392 | .Pp | 392 | .Pp |
393 | .Ar port | 393 | .Ar port |
394 | can be a specified as a numeric port number, or as a service name. | 394 | can be a specified as a numeric port number or as a service name. |
395 | Ports may be specified in a range of the form | 395 | Port ranges may be specified as numeric port numbers of the form |
396 | .Ar nn Ns - Ns Ar mm . | 396 | .Ar nn Ns - Ns Ar mm . |
397 | In general, | 397 | In general, |
398 | a destination port must be specified, | 398 | a destination port must be specified, |
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index e0966f1952..adfad2dcd9 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.199 2018/11/29 14:25:06 tedu Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.200 2018/12/27 17:22:45 tedu 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. |
@@ -42,6 +42,7 @@ | |||
42 | #include <netinet/ip.h> | 42 | #include <netinet/ip.h> |
43 | #include <arpa/telnet.h> | 43 | #include <arpa/telnet.h> |
44 | 44 | ||
45 | #include <ctype.h> | ||
45 | #include <err.h> | 46 | #include <err.h> |
46 | #include <errno.h> | 47 | #include <errno.h> |
47 | #include <limits.h> | 48 | #include <limits.h> |
@@ -1427,7 +1428,7 @@ build_ports(char *p) | |||
1427 | int hi, lo, cp; | 1428 | int hi, lo, cp; |
1428 | int x = 0; | 1429 | int x = 0; |
1429 | 1430 | ||
1430 | if ((n = strchr(p, '-')) != NULL) { | 1431 | if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) { |
1431 | *n = '\0'; | 1432 | *n = '\0'; |
1432 | n++; | 1433 | n++; |
1433 | 1434 | ||