diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-10-26 21:33:30 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-10-26 21:33:30 +0000 |
commit | 453d034e87d716340f1ee11254512674e252f73b (patch) | |
tree | 3fa50f973af68a265a1fad0a475fccd0da241557 /usr.bin | |
parent | 83a0e50d6b854ee8bb9ee67210f462726ac7603d (diff) |
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).
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/nc/netcat.c | 14 | ||||
-rw-r--r-- | usr.bin/telnet/commands.c | 6 | ||||
-rw-r--r-- | usr.bin/telnet/externs.h | 4 | ||||
-rw-r--r-- | usr.bin/telnet/main.c | 7 |
4 files changed, 15 insertions, 16 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index dfa3a6a25b5..2211508c834 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.116 2013/10/21 09:12:55 phessler Exp $ */ +/* $OpenBSD: netcat.c,v 1.117 2013/10/26 21:33:29 sthen Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -87,7 +87,7 @@ int Iflag; /* TCP receive buffer size */ int Oflag; /* TCP send buffer size */ int Sflag; /* TCP MD5 signature option */ int Tflag = -1; /* IP Type of Service */ -u_int rtableid; +int rtableid = -1; int timeout = -1; int family = AF_UNSPEC; @@ -202,7 +202,7 @@ main(int argc, char *argv[]) uflag = 1; break; case 'V': - rtableid = (unsigned int)strtonum(optarg, 0, + rtableid = (int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) errx(1, "rtable %s: %s", errstr, optarg); @@ -589,8 +589,8 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) res0->ai_protocol)) < 0) continue; - if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, - sizeof(rtableid)) == -1) + if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1)) err(1, "setsockopt SO_RTABLE"); /* Bind to a local port or source address if specified. */ @@ -698,8 +698,8 @@ local_listen(char *host, char *port, struct addrinfo hints) res0->ai_protocol)) < 0) continue; - if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, - sizeof(rtableid)) == -1) + if (rtableid >= 0 && (setsockopt(s, IPPROTO_IP, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1)) err(1, "setsockopt SO_RTABLE"); ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 0e52c0485ab..ae9c7847814 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.54 2013/10/21 09:02:37 phessler Exp $ */ +/* $OpenBSD: commands.c,v 1.55 2013/10/26 21:33:29 sthen Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -2396,8 +2396,8 @@ tn(argc, argv) if (net < 0) continue; - if (setsockopt(net, SOL_SOCKET, SO_RTABLE, &rtableid, - sizeof(rtableid)) == -1) + if (rtableid >= 0 && (setsockopt(net, SOL_SOCKET, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1)) perror("setsockopt (SO_RTABLE)"); if (aliasp) { diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index c523ce02c66..80b809978bb 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.16 2010/07/03 04:44:51 guenther Exp $ */ +/* $OpenBSD: externs.h,v 1.17 2013/10/26 21:33:29 sthen Exp $ */ /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */ /* @@ -108,7 +108,7 @@ extern void (*encrypt_output) (unsigned char *, int); extern int (*decrypt_input) (int); #endif -extern u_int rtableid; /* routing table to use */ +extern int rtableid; /* routing table to use */ /* * We keep track of each side of the option negotiation. diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index e94b1ccec55..00a86a657e6 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.21 2013/10/21 09:12:55 phessler Exp $ */ +/* $OpenBSD: main.c,v 1.22 2013/10/26 21:33:29 sthen Exp $ */ /* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */ /* @@ -54,7 +54,7 @@ static int default_forward=0; #endif int family = AF_UNSPEC; -u_int rtableid; +int rtableid = -1; /* * Initialize variables. @@ -173,7 +173,6 @@ main(argc, argv) * passed */ autologin = -1; - rtableid = getrtable(); while ((ch = getopt(argc, argv, "4678DEKLS:X:ab:cde:fFk:l:n:rt:V:x")) != -1) { @@ -327,7 +326,7 @@ main(argc, argv) #endif break; case 'V': - rtableid = (unsigned int)strtonum(optarg, 0, + rtableid = (int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) { fprintf(stderr, "%s: Warning: " |