diff options
author | sthen <> | 2013-10-26 21:33:29 +0000 |
---|---|---|
committer | sthen <> | 2013-10-26 21:33:29 +0000 |
commit | 7bc9ea1392b524e778a39ced35b01b8cf2a96d1e (patch) | |
tree | 375a593fa1bf4d4926e8b7358f208361b9b06a3b | |
parent | 99f36bb6bbe7e097ecb64645a1a37030afe8efed (diff) | |
download | openbsd-7bc9ea1392b524e778a39ced35b01b8cf2a96d1e.tar.gz openbsd-7bc9ea1392b524e778a39ced35b01b8cf2a96d1e.tar.bz2 openbsd-7bc9ea1392b524e778a39ced35b01b8cf2a96d1e.zip |
Only use setsockopt(..SO_RTABLE..) if the -V flag is given to nc/telnet,
same style as traceroute6 (change to int and use -1 as a flag, so rtable 0
can still be used as an explicit parameter).
-rw-r--r-- | src/usr.bin/nc/netcat.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index dfa3a6a25b..2211508c83 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.116 2013/10/21 09:12:55 phessler Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.117 2013/10/26 21:33:29 sthen Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * | 4 | * |
@@ -87,7 +87,7 @@ int Iflag; /* TCP receive buffer size */ | |||
87 | int Oflag; /* TCP send buffer size */ | 87 | int Oflag; /* TCP send buffer size */ |
88 | int Sflag; /* TCP MD5 signature option */ | 88 | int Sflag; /* TCP MD5 signature option */ |
89 | int Tflag = -1; /* IP Type of Service */ | 89 | int Tflag = -1; /* IP Type of Service */ |
90 | u_int rtableid; | 90 | int rtableid = -1; |
91 | 91 | ||
92 | int timeout = -1; | 92 | int timeout = -1; |
93 | int family = AF_UNSPEC; | 93 | int family = AF_UNSPEC; |
@@ -202,7 +202,7 @@ main(int argc, char *argv[]) | |||
202 | uflag = 1; | 202 | uflag = 1; |
203 | break; | 203 | break; |
204 | case 'V': | 204 | case 'V': |
205 | rtableid = (unsigned int)strtonum(optarg, 0, | 205 | rtableid = (int)strtonum(optarg, 0, |
206 | RT_TABLEID_MAX, &errstr); | 206 | RT_TABLEID_MAX, &errstr); |
207 | if (errstr) | 207 | if (errstr) |
208 | errx(1, "rtable %s: %s", errstr, optarg); | 208 | errx(1, "rtable %s: %s", errstr, optarg); |
@@ -589,8 +589,8 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) | |||
589 | res0->ai_protocol)) < 0) | 589 | res0->ai_protocol)) < 0) |
590 | continue; | 590 | continue; |
591 | 591 | ||
592 | if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, | 592 | if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, |
593 | sizeof(rtableid)) == -1) | 593 | &rtableid, sizeof(rtableid)) == -1)) |
594 | err(1, "setsockopt SO_RTABLE"); | 594 | err(1, "setsockopt SO_RTABLE"); |
595 | 595 | ||
596 | /* Bind to a local port or source address if specified. */ | 596 | /* Bind to a local port or source address if specified. */ |
@@ -698,8 +698,8 @@ local_listen(char *host, char *port, struct addrinfo hints) | |||
698 | res0->ai_protocol)) < 0) | 698 | res0->ai_protocol)) < 0) |
699 | continue; | 699 | continue; |
700 | 700 | ||
701 | if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, | 701 | if (rtableid >= 0 && (setsockopt(s, IPPROTO_IP, SO_RTABLE, |
702 | sizeof(rtableid)) == -1) | 702 | &rtableid, sizeof(rtableid)) == -1)) |
703 | err(1, "setsockopt SO_RTABLE"); | 703 | err(1, "setsockopt SO_RTABLE"); |
704 | 704 | ||
705 | ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); | 705 | ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); |