diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index c103aa6350..5a6cb9dadd 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.171 2016/11/30 07:56:23 mestre Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.172 2017/02/05 01:39:14 jca 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. |
| @@ -148,8 +148,8 @@ main(int argc, char *argv[]) | |||
| 148 | struct servent *sv; | 148 | struct servent *sv; |
| 149 | socklen_t len; | 149 | socklen_t len; |
| 150 | struct sockaddr_storage cliaddr; | 150 | struct sockaddr_storage cliaddr; |
| 151 | char *proxy; | 151 | char *proxy, *proxyport = NULL; |
| 152 | const char *errstr, *proxyhost = "", *proxyport = NULL; | 152 | const char *errstr; |
| 153 | struct addrinfo proxyhints; | 153 | struct addrinfo proxyhints; |
| 154 | char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; | 154 | char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; |
| 155 | struct tls_config *tls_cfg = NULL; | 155 | struct tls_config *tls_cfg = NULL; |
| @@ -426,15 +426,29 @@ main(int argc, char *argv[]) | |||
| 426 | if (family == AF_UNIX) | 426 | if (family == AF_UNIX) |
| 427 | errx(1, "no proxy support for unix sockets"); | 427 | errx(1, "no proxy support for unix sockets"); |
| 428 | 428 | ||
| 429 | /* XXX IPv6 transport to proxy would probably work */ | ||
| 430 | if (family == AF_INET6) | ||
| 431 | errx(1, "no proxy support for IPv6"); | ||
| 432 | |||
| 433 | if (sflag) | 429 | if (sflag) |
| 434 | errx(1, "no proxy support for local source address"); | 430 | errx(1, "no proxy support for local source address"); |
| 435 | 431 | ||
| 436 | proxyhost = strsep(&proxy, ":"); | 432 | if (*proxy == '[') { |
| 437 | proxyport = proxy; | 433 | ++proxy; |
| 434 | proxyport = strchr(proxy, ']'); | ||
| 435 | if (proxyport == NULL) | ||
| 436 | errx(1, "missing closing bracket in proxy"); | ||
| 437 | *proxyport++ = '\0'; | ||
| 438 | if (*proxyport == '\0') | ||
| 439 | /* Use default proxy port. */ | ||
| 440 | proxyport = NULL; | ||
| 441 | else { | ||
| 442 | if (*proxyport == ':') | ||
| 443 | ++proxyport; | ||
| 444 | else | ||
| 445 | errx(1, "garbage proxy port delimiter"); | ||
| 446 | } | ||
| 447 | } else { | ||
| 448 | proxyport = strrchr(proxy, ':'); | ||
| 449 | if (proxyport != NULL) | ||
| 450 | *proxyport++ = '\0'; | ||
| 451 | } | ||
| 438 | 452 | ||
| 439 | memset(&proxyhints, 0, sizeof(struct addrinfo)); | 453 | memset(&proxyhints, 0, sizeof(struct addrinfo)); |
| 440 | proxyhints.ai_family = family; | 454 | proxyhints.ai_family = family; |
| @@ -617,7 +631,7 @@ main(int argc, char *argv[]) | |||
| 617 | } | 631 | } |
| 618 | if (xflag) | 632 | if (xflag) |
| 619 | s = socks_connect(host, portlist[i], hints, | 633 | s = socks_connect(host, portlist[i], hints, |
| 620 | proxyhost, proxyport, proxyhints, socksv, | 634 | proxy, proxyport, proxyhints, socksv, |
| 621 | Pflag); | 635 | Pflag); |
| 622 | else | 636 | else |
| 623 | s = remote_connect(host, portlist[i], hints); | 637 | s = remote_connect(host, portlist[i], hints); |
