summaryrefslogtreecommitdiff
path: root/usr.bin/telnet
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2013-10-26 21:33:30 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2013-10-26 21:33:30 +0000
commit453d034e87d716340f1ee11254512674e252f73b (patch)
tree3fa50f973af68a265a1fad0a475fccd0da241557 /usr.bin/telnet
parent83a0e50d6b854ee8bb9ee67210f462726ac7603d (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/telnet')
-rw-r--r--usr.bin/telnet/commands.c6
-rw-r--r--usr.bin/telnet/externs.h4
-rw-r--r--usr.bin/telnet/main.c7
3 files changed, 8 insertions, 9 deletions
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: "