CVS commit: src/usr.bin/telnet

2021-01-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan  9 18:26:03 UTC 2021

Modified Files:
src/usr.bin/telnet: commands.c

Log Message:
preserve errno because we are doing system calls between error printing
and error setting.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.bin/telnet/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.78 src/usr.bin/telnet/commands.c:1.79
--- src/usr.bin/telnet/commands.c:1.78	Sat Jan  9 13:22:42 2021
+++ src/usr.bin/telnet/commands.c	Sat Jan  9 13:26:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.78 2021/01/09 18:22:42 christos Exp $	*/
+/*	$NetBSD: commands.c,v 1.79 2021/01/09 18:26:03 christos Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.78 2021/01/09 18:22:42 christos Exp $");
+__RCSID("$NetBSD: commands.c,v 1.79 2021/01/09 18:26:03 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -2086,7 +2086,7 @@ tn(int argc, char *argv[])
 {
 struct addrinfo hints, *res, *res0;
 const char *cause = "telnet: unknown";
-int error;
+int error, serrno = 0;
 char *cmd, *hostp = 0;
 const char *portp = 0;
 const char *user = 0;
@@ -2193,6 +2193,7 @@ tn(int argc, char *argv[])
 	printf("Trying %s...\n", sockaddr_ntop(res->ai_addr));
 	net = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
 	if (net < 0) {
+	serrno = errno;
 	cause = "telnet: socket";
 	continue;
 	}
@@ -2203,11 +2204,13 @@ tn(int argc, char *argv[])
 
 #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
 	if (setpolicy(net, res, ipsec_policy_in) < 0) {
+	serrno = errno;
 	(void) NetClose(net);
 	net = -1;
 	continue;
 	}
 	if (setpolicy(net, res, ipsec_policy_out) < 0) {
+	serrno = errno;
 	(void) NetClose(net);
 	net = -1;
 	continue;
@@ -2218,6 +2221,7 @@ tn(int argc, char *argv[])
 	if (res->ai_next) {
 		warn("Connect to address %s: ", sockaddr_ntop(res->ai_addr));
 	}
+	serrno = errno;
 	cause = "Unable to connect to remote host";
 	(void) NetClose(net);
 	net = -1;
@@ -2232,7 +2236,7 @@ tn(int argc, char *argv[])
 }
 freeaddrinfo(res0);
 if (net < 0 || connected == 0) {
-	warn("%s", cause);
+	warnc(serrno, "%s", cause);
 	return 0;
 }
 



CVS commit: src/usr.bin/telnet

2021-01-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan  9 18:22:43 UTC 2021

Modified Files:
src/usr.bin/telnet: commands.c

Log Message:
restore perror -> warn (reported by Havard Eidnes)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/telnet/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.77 src/usr.bin/telnet/commands.c:1.78
--- src/usr.bin/telnet/commands.c:1.77	Fri Oct  4 07:39:44 2019
+++ src/usr.bin/telnet/commands.c	Sat Jan  9 13:22:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.77 2019/10/04 11:39:44 mrg Exp $	*/
+/*	$NetBSD: commands.c,v 1.78 2021/01/09 18:22:42 christos Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.77 2019/10/04 11:39:44 mrg Exp $");
+__RCSID("$NetBSD: commands.c,v 1.78 2021/01/09 18:22:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -2232,7 +2232,7 @@ tn(int argc, char *argv[])
 }
 freeaddrinfo(res0);
 if (net < 0 || connected == 0) {
-	warnx("%s", cause);
+	warn("%s", cause);
 	return 0;
 }
 



CVS commit: src/usr.bin/telnet

2019-01-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan  5 06:59:46 UTC 2019

Modified Files:
src/usr.bin/telnet: Makefile

Log Message:
Bump WARNS to 5, and remove unnecessary -Wno (tested with pkgsrc clang 7)


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/telnet/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.55 src/usr.bin/telnet/Makefile:1.56
--- src/usr.bin/telnet/Makefile:1.55	Sat Jan  5 06:56:03 2019
+++ src/usr.bin/telnet/Makefile	Sat Jan  5 06:59:46 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.55 2019/01/05 06:56:03 maya Exp $
+#	$NetBSD: Makefile,v 1.56 2019/01/05 06:59:46 maya Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -30,8 +30,7 @@
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 #
 
-WARNS?=	4	# XXX -Wshadow etc.  fix asap
-CWARNFLAGS.clang+=	-Wno-tautological-compare -Wno-format-security
+WARNS?=	5
 
 .include 
 



CVS commit: src/usr.bin/telnet

2019-01-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan  5 06:56:03 UTC 2019

Modified Files:
src/usr.bin/telnet: Makefile

Log Message:
Remove advertising clause, permitted by the copyright author.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/telnet/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.54 src/usr.bin/telnet/Makefile:1.55
--- src/usr.bin/telnet/Makefile:1.54	Thu Dec 13 04:49:19 2018
+++ src/usr.bin/telnet/Makefile	Sat Jan  5 06:56:03 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.54 2018/12/13 04:49:19 maya Exp $
+#	$NetBSD: Makefile,v 1.55 2019/01/05 06:56:03 maya Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -11,11 +11,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #notice, this list of conditions and the following disclaimer in the
 #documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-#must display the following acknowledgement:
-#	This product includes software developed by the University of
-#	California, Berkeley and its contributors.
-# 4. Neither the name of the University nor the names of its contributors
+# 3. Neither the name of the University nor the names of its contributors
 #may be used to endorse or promote products derived from this software
 #without specific prior written permission.
 #



CVS commit: src/usr.bin/telnet

2019-01-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan  5 06:47:24 UTC 2019

Modified Files:
src/usr.bin/telnet: commands.c telnet.c utilities.c

Log Message:
unifdef compatibility for old BSD servers. This has been
disabled, so no binary change. from openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/telnet/commands.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.74 src/usr.bin/telnet/commands.c:1.75
--- src/usr.bin/telnet/commands.c:1.74	Sat Jan  5 06:30:05 2019
+++ src/usr.bin/telnet/commands.c	Sat Jan  5 06:47:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.74 2019/01/05 06:30:05 maya Exp $	*/
+/*	$NetBSD: commands.c,v 1.75 2019/01/05 06:47:24 maya Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.74 2019/01/05 06:30:05 maya Exp $");
+__RCSID("$NetBSD: commands.c,v 1.75 2019/01/05 06:47:24 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -1542,10 +1542,6 @@ struct envlist EnvList[] = {
 { "send",	"Send an environment variable", env_send,	1 },
 { "list",	"List the current environment variables",
 		env_list,	0 },
-#if defined(OLD_ENVIRON) && defined(ENV_HACK)
-{ "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
-		env_varval,1 },
-#endif
 { "help",	0,env_help,		0 },
 { "?",	"Print help information",	env_help,		0 },
 { .name = 0 },
@@ -1745,9 +1741,6 @@ env_send(const char *var, char *d)
 	struct env_lst *ep;
 
 	if (my_state_is_wont(TELOPT_NEW_ENVIRON)
-#ifdef	OLD_ENVIRON
-	&& my_state_is_wont(TELOPT_OLD_ENVIRON)
-#endif
 		) {
 		fprintf(stderr,
 		"Cannot send '%s': Telnet ENVIRON option not enabled\n",
@@ -1807,43 +1800,6 @@ env_getvalue(const char *var)
 	return NULL;
 }
 
-#if defined(OLD_ENVIRON) && defined(ENV_HACK)
-void
-env_varval(const unsigned char *what)
-{
-	extern int old_env_var, old_env_value, env_auto;
-	int len = strlen(what);
-
-	if (len == 0)
-		goto unknown;
-
-	if (strncasecmp(what, "status", len) == 0) {
-		if (env_auto)
-			printf("%s%s", "VAR and VALUE are/will be ",
-	"determined automatically\n");
-		if (old_env_var == OLD_ENV_VAR)
-			printf("VAR and VALUE set to correct definitions\n");
-		else
-			printf("VAR and VALUE definitions are reversed\n");
-	} else if (strncasecmp(what, "auto", len) == 0) {
-		env_auto = 1;
-		old_env_var = OLD_ENV_VALUE;
-		old_env_value = OLD_ENV_VAR;
-	} else if (strncasecmp(what, "right", len) == 0) {
-		env_auto = 0;
-		old_env_var = OLD_ENV_VAR;
-		old_env_value = OLD_ENV_VALUE;
-	} else if (strncasecmp(what, "wrong", len) == 0) {
-		env_auto = 0;
-		old_env_var = OLD_ENV_VALUE;
-		old_env_value = OLD_ENV_VAR;
-	} else {
-unknown:
-		printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\n");
-	}
-}
-#endif
-
 #ifdef AUTHENTICATION
 /*
  * The AUTHENTICATE command.

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.41 src/usr.bin/telnet/telnet.c:1.42
--- src/usr.bin/telnet/telnet.c:1.41	Fri Dec 14 23:40:17 2018
+++ src/usr.bin/telnet/telnet.c	Sat Jan  5 06:47:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.41 2018/12/14 23:40:17 christos Exp $	*/
+/*	$NetBSD: telnet.c,v 1.42 2019/01/05 06:47:24 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.41 2018/12/14 23:40:17 christos Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.42 2019/01/05 06:47:24 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -133,11 +133,7 @@ cc_t echoc;
 #define	TS_SE		8		/* looking for sub-option end */
 
 static int	telrcv_state;
-#ifdef	OLD_ENVIRON
-unsigned char telopt_environ = TELOPT_NEW_ENVIRON;
-#else
 # define telopt_environ TELOPT_NEW_ENVIRON
-#endif
 
 jmp_buf	toplevel = { 0 };
 
@@ -461,16 +457,6 @@ dooption(int option)
 		break;
 
 	case TELOPT_NEW_ENVIRON:	/* New environment variable option */
-#ifdef	OLD_ENVIRON
-		if (my_state_is_will(TELOPT_OLD_ENVIRON))
-			send_wont(TELOPT_OLD_ENVIRON, 1); /* turn off the old */
-		goto env_common;
-	case TELOPT_OLD_ENVIRON:	/* Old environment variable option */
-		if (my_state_is_will(TELOPT_NEW_ENVIRON))
-			break;		/* Don't enable if new one is in use! */
-	env_common:
-		telopt_environ = option;
-#endif
 		new_state_ok = 1;
 		break;
 
@@ -546,16 +532,6 @@ dontoption(int option)
 	case TELOPT_LINEMODE:
 		linemode = 0;	/* put us back to the default state */
 		break;
-#ifdef	OLD_ENVIRON
-	case TELOPT_NEW_ENVIRON:
-		/*
-		 * The new environ option wasn't recognized, try
-		 * the old one.
-		 

CVS commit: src/usr.bin/telnet

2019-01-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jan  5 06:30:05 UTC 2019

Modified Files:
src/usr.bin/telnet: commands.c

Log Message:
Avoid unnecessary casts, from openbsd. No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/telnet/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.73 src/usr.bin/telnet/commands.c:1.74
--- src/usr.bin/telnet/commands.c:1.73	Fri Dec 14 23:40:17 2018
+++ src/usr.bin/telnet/commands.c	Sat Jan  5 06:30:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.73 2018/12/14 23:40:17 christos Exp $	*/
+/*	$NetBSD: commands.c,v 1.74 2019/01/05 06:30:05 maya Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.73 2018/12/14 23:40:17 christos Exp $");
+__RCSID("$NetBSD: commands.c,v 1.74 2019/01/05 06:30:05 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -280,16 +280,16 @@ control(cc_t c)
 	}
 	if (uic >= 0x80) {
 		buf[0] = '\\';
-		buf[1] = (char)(((c >> 6) & 07) + '0');
-		buf[2] = (char)(((c >> 3) & 07) + '0');
-		buf[3] = (char)((c & 07) + '0');
+		buf[1] = ((c >> 6) & 07) + '0';
+		buf[2] = ((c >> 3) & 07) + '0';
+		buf[3] = (c & 07) + '0';
 		buf[4] = '\0';
 	} else if (uic >= 0x20) {
-		buf[0] = (char)c;
+		buf[0] = c;
 		buf[1] = '\0';
 	} else {
 		buf[0] = '^';
-		buf[1] = (char)('@' + c);
+		buf[1] = '@' + c;
 		buf[2] = '\0';
 	}
 	return (buf);



CVS commit: src/usr.bin/telnet

2018-12-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Dec 15 22:56:51 UTC 2018

Removed Files:
src/usr.bin/telnet: README

Log Message:
Remove README relevant to 1995 telnet.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r0 src/usr.bin/telnet/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/telnet

2018-12-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 15 22:17:02 UTC 2018

Modified Files:
src/usr.bin/telnet: telnet.1

Log Message:
Remove reference to krb_realmofhost(3) which does not exist.

Someone who speaks kerberos might want to check the -k description.

Remove some macros that do nothing and use \(em.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/telnet/telnet.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.1
diff -u src/usr.bin/telnet/telnet.1:1.35 src/usr.bin/telnet/telnet.1:1.36
--- src/usr.bin/telnet/telnet.1:1.35	Sat Dec 15 22:12:15 2018
+++ src/usr.bin/telnet/telnet.1	Sat Dec 15 22:17:02 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: telnet.1,v 1.35 2018/12/15 22:12:15 maya Exp $
+.\"	$NetBSD: telnet.1,v 1.36 2018/12/15 22:17:02 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -158,8 +158,7 @@ If Kerberos authentication is being used
 option requests that telnet obtain tickets for the remote host in
 realm
 .Ar realm
-instead of the remote host's realm, as determined by
-.Xr krb_realmofhost 3 .
+instead of the remote host's realm.
 .It Fl l Ar user
 When connecting to the remote system, if the remote system
 understands the
@@ -314,7 +313,6 @@ Only enough of each command to uniquely 
 and
 .Ic display
 commands).
-.Pp
 .Bl -tag -width "mode type"
 .It Ic auth Ar argument ...
 The auth command manipulates the information sent through the
@@ -612,7 +610,6 @@ An end of file (in command mode) will al
 Sends one or more special character sequences to the remote host.
 The following are the arguments which may be specified
 (more than one argument may be specified at a time):
-.Pp
 .Bl -tag -width escape
 .It Ic abort
 Sends the
@@ -703,7 +700,7 @@ This sequence is sent as
 urgent
 data (and may not work if the remote system is a
 .Bx 4.2
-system -- if
+system \(em if
 it doesn't work, a lower case \*(Lqr\*(Rq may be echoed on the terminal).
 .It Ic do Ar cmd
 .It Ic dont Ar cmd



CVS commit: src/usr.bin/telnet

2018-12-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Dec 15 22:12:15 UTC 2018

Modified Files:
src/usr.bin/telnet: telnet.1

Log Message:
You can encrypt outside of north america now.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/telnet/telnet.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.1
diff -u src/usr.bin/telnet/telnet.1:1.34 src/usr.bin/telnet/telnet.1:1.35
--- src/usr.bin/telnet/telnet.1:1.34	Mon Jul  3 21:34:22 2017
+++ src/usr.bin/telnet/telnet.1	Sat Dec 15 22:12:15 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: telnet.1,v 1.34 2017/07/03 21:34:22 wiz Exp $
+.\"	$NetBSD: telnet.1,v 1.35 2018/12/15 22:12:15 maya Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)telnet.1	8.4 (Berkeley) 2/3/94
 .\"
-.Dd October 28, 2003
+.Dd December 16, 2018
 .Dt TELNET 1
 .Os
 .Sh NAME
@@ -197,9 +197,6 @@ unless modified by the
 option.
 .It Fl x
 Turns on encryption of the data stream if possible.
-This
-option is not available outside of the United States and
-Canada.
 .It Ar host
 Indicates the official name, an alias, or the Internet address
 of a remote host.



CVS commit: src/usr.bin/telnet

2018-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec 14 23:40:17 UTC 2018

Modified Files:
src/usr.bin/telnet: authenc.c commands.c externs.h main.c network.c
ring.c telnet.c utilities.c

Log Message:
minor cleanup:
- more const
- prevent overflow of the argument vector
- change a lot of unsigned to signed to eliminate casts


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/telnet/authenc.c
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/telnet/commands.c
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/telnet/main.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/telnet/network.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/telnet/ring.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/authenc.c
diff -u src/usr.bin/telnet/authenc.c:1.13 src/usr.bin/telnet/authenc.c:1.14
--- src/usr.bin/telnet/authenc.c:1.13	Mon Jan  9 11:08:55 2012
+++ src/usr.bin/telnet/authenc.c	Fri Dec 14 18:40:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $	*/
+/*	$NetBSD: authenc.c,v 1.14 2018/12/14 23:40:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)authenc.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $");
+__RCSID("$NetBSD: authenc.c,v 1.14 2018/12/14 23:40:17 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -54,13 +54,15 @@ __RCSID("$NetBSD: authenc.c,v 1.13 2012/
 int
 telnet_net_write(unsigned char *str, int len)
 {
-	if (NETROOM() > len) {
-		ring_supply_data(, str, len);
-		if (str[0] == IAC && str[1] == SE)
-			printsub('>', [2], len-2);
-		return(len);
+	if (NETROOM() <= len)
+		return 0;
+	ring_supply_data(, str, len);
+	if (str[0] == IAC && str[1] == SE) {
+		if (len < 2)
+			return 0;
+		printsub('>', [2], len - 2);
 	}
-	return(0);
+	return len;
 }
 
 void
@@ -77,13 +79,13 @@ net_encrypt(void)
 int
 telnet_spin(void)
 {
-	return(-1);
+	return -1;
 }
 
 char *
 telnet_getenv(char *val)
 {
-	return((char *)env_getvalue((unsigned char *)val));
+	return env_getvalue(val);
 }
 
 char *
@@ -93,15 +95,18 @@ telnet_gets(char *prmpt, char *result, i
 	int om = globalmode;
 	char *res;
 
+	if (length < 0)
+		abort();
+
 	TerminalNewMode(-1);
 	if (echo) {
 		printf("%s", prmpt);
 		res = fgets(result, length, stdin);
 	} else if ((res = getpass(prmpt)) != NULL) {
-		strlcpy(result, res, length);
+		strlcpy(result, res, (size_t)length);
 		res = result;
 	}
 	TerminalNewMode(om);
-	return(res);
+	return res;
 }
 #endif	/* defined(AUTHENTICATION) || defined(ENCRYPTION) */

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.72 src/usr.bin/telnet/commands.c:1.73
--- src/usr.bin/telnet/commands.c:1.72	Fri Dec 14 01:08:18 2018
+++ src/usr.bin/telnet/commands.c	Fri Dec 14 18:40:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.72 2018/12/14 06:08:18 maya Exp $	*/
+/*	$NetBSD: commands.c,v 1.73 2018/12/14 23:40:17 christos Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.72 2018/12/14 06:08:18 maya Exp $");
+__RCSID("$NetBSD: commands.c,v 1.73 2018/12/14 23:40:17 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -81,6 +81,7 @@ __RCSID("$NetBSD: commands.c,v 1.72 2018
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -122,15 +123,15 @@ static int margc;
 static char *margv[20];
 
 static void makeargv(void);
-static int special(char *);
+static int special(const char *);
 static const char *control(cc_t);
 static int sendcmd(int, char **);
-static int send_esc(char *);
-static int send_docmd(char *);
-static int send_dontcmd(char *);
-static int send_willcmd(char *);
-static int send_wontcmd(char *);
-static int send_help(char *);
+static int send_esc(const char *);
+static int send_docmd(const char *);
+static int send_dontcmd(const char *);
+static int send_willcmd(const char *);
+static int send_wontcmd(const char *);
+static int send_help(const char *);
 static int lclchars(int);
 static int togdebug(int);
 static int togcrlf(int);
@@ -140,7 +141,7 @@ static int togxbinary(int);
 static int togglehelp(int);
 static void settogglehelp(int);
 static int toggle(int, char *[]);
-static struct setlist *getset(char *);
+static struct setlist *getset(const char *);
 static int setcmd(int, char *[]);
 static int unsetcmd(int, char *[]);
 static int dokludgemode(int);
@@ -153,33 +154,45 @@ static int setescape(int, char *[]);
 static int togcrmod(int, char *[]);
 static int bye(int, char *[]);
 static void slc_help(int);
-static struct slclist *getslc(char *);
+static struct slclist *getslc(const 

CVS commit: src/usr.bin/telnet

2018-12-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Dec 14 06:28:49 UTC 2018

Modified Files:
src/usr.bin/telnet: sys_bsd.c

Log Message:
Remove unneeded casts


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/telnet/sys_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/sys_bsd.c
diff -u src/usr.bin/telnet/sys_bsd.c:1.39 src/usr.bin/telnet/sys_bsd.c:1.40
--- src/usr.bin/telnet/sys_bsd.c:1.39	Fri Dec 14 06:27:40 2018
+++ src/usr.bin/telnet/sys_bsd.c	Fri Dec 14 06:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_bsd.c,v 1.39 2018/12/14 06:27:40 maya Exp $	*/
+/*	$NetBSD: sys_bsd.c,v 1.40 2018/12/14 06:28:49 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 from: static char sccsid[] = "@(#)sys_bsd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_bsd.c,v 1.39 2018/12/14 06:27:40 maya Exp $");
+__RCSID("$NetBSD: sys_bsd.c,v 1.40 2018/12/14 06:28:49 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -416,8 +416,8 @@ TerminalNewMode(int f)
 if (tcsetattr(tin, TCSADRAIN, _tc) < 0)
 	tcsetattr(tin, TCSANOW, _tc);
 
-ioctl(tin, FIONBIO, (char *));
-ioctl(tout, FIONBIO, (char *));
+ioctl(tin, FIONBIO, );
+ioctl(tout, FIONBIO, );
 
 }
 



CVS commit: src/usr.bin/telnet

2018-12-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Dec 14 06:27:40 UTC 2018

Modified Files:
src/usr.bin/telnet: sys_bsd.c

Log Message:
Remove some effectively if 0'd code.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/telnet/sys_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/sys_bsd.c
diff -u src/usr.bin/telnet/sys_bsd.c:1.38 src/usr.bin/telnet/sys_bsd.c:1.39
--- src/usr.bin/telnet/sys_bsd.c:1.38	Fri Dec 14 06:17:30 2018
+++ src/usr.bin/telnet/sys_bsd.c	Fri Dec 14 06:27:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_bsd.c,v 1.38 2018/12/14 06:17:30 maya Exp $	*/
+/*	$NetBSD: sys_bsd.c,v 1.39 2018/12/14 06:27:40 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 from: static char sccsid[] = "@(#)sys_bsd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_bsd.c,v 1.38 2018/12/14 06:17:30 maya Exp $");
+__RCSID("$NetBSD: sys_bsd.c,v 1.39 2018/12/14 06:27:40 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -76,32 +76,6 @@ int
 struct	termios old_tc = { .c_iflag = 0 };
 extern struct termios new_tc;
 
-# ifndef	TCSANOW
-#  ifdef TCSETS
-#   define	TCSANOW		TCSETS
-#   define	TCSADRAIN	TCSETSW
-#   define	tcgetattr(f, t) ioctl(f, TCGETS, (char *)t)
-#  else
-#   ifdef TCSETA
-#define	TCSANOW		TCSETA
-#define	TCSADRAIN	TCSETAW
-#define	tcgetattr(f, t) ioctl(f, TCGETA, (char *)t)
-#   else
-#define	TCSANOW		TIOCSETA
-#define	TCSADRAIN	TIOCSETAW
-#define	tcgetattr(f, t) ioctl(f, TIOCGETA, (char *)t)
-#   endif
-#  endif
-#  define	tcsetattr(f, a, t) ioctl(f, a, (char *)t)
-#  define	cfgetospeed(ptr)	((ptr)->c_cflag)
-#  ifdef CIBAUD
-#   define	cfgetispeed(ptr)	(((ptr)->c_cflag) >> IBSHIFT)
-#  else
-#   define	cfgetispeed(ptr)	cfgetospeed(ptr)
-#  endif
-# endif /* TCSANOW */
-
-
 void
 init_sys(void)
 {



CVS commit: src/usr.bin/telnet

2018-12-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Dec 14 06:17:31 UTC 2018

Modified Files:
src/usr.bin/telnet: externs.h sys_bsd.c

Log Message:
Inline the only use of NetNonblockingIO.
While here inline SetSockOpt. From openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/telnet/sys_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/externs.h
diff -u src/usr.bin/telnet/externs.h:1.42 src/usr.bin/telnet/externs.h:1.43
--- src/usr.bin/telnet/externs.h:1.42	Fri Dec 14 06:08:18 2018
+++ src/usr.bin/telnet/externs.h	Fri Dec 14 06:17:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.42 2018/12/14 06:08:18 maya Exp $	*/
+/*	$NetBSD: externs.h,v 1.43 2018/12/14 06:17:30 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -250,7 +250,6 @@ void TerminalNewMode(int);
 void TerminalSpeeds(long *, long *);
 int TerminalWindowSize(long *, long *);
 int NetClose(int);
-void NetNonblockingIO(int, int);
 void NetSigIO(int, int);
 void NetSetPgrp(int);
 void sys_telnet_init(void);

Index: src/usr.bin/telnet/sys_bsd.c
diff -u src/usr.bin/telnet/sys_bsd.c:1.37 src/usr.bin/telnet/sys_bsd.c:1.38
--- src/usr.bin/telnet/sys_bsd.c:1.37	Thu Dec 13 09:20:05 2018
+++ src/usr.bin/telnet/sys_bsd.c	Fri Dec 14 06:17:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_bsd.c,v 1.37 2018/12/13 09:20:05 maya Exp $	*/
+/*	$NetBSD: sys_bsd.c,v 1.38 2018/12/14 06:17:30 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 from: static char sccsid[] = "@(#)sys_bsd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_bsd.c,v 1.37 2018/12/13 09:20:05 maya Exp $");
+__RCSID("$NetBSD: sys_bsd.c,v 1.38 2018/12/14 06:17:30 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -481,14 +481,6 @@ NetClose(int fd)
 return close(fd);
 }
 
-
-void
-NetNonblockingIO(int fd, int onoff)
-{
-ioctl(fd, FIONBIO, (char *));
-}
-
-
 /*
  * Various signal handling routines.
  */
@@ -553,6 +545,8 @@ ayt(int sig)
 void
 sys_telnet_init(void)
 {
+int one = 1;
+
 (void) signal(SIGINT, intr);
 (void) signal(SIGQUIT, intr2);
 (void) signal(SIGPIPE, SIG_IGN);
@@ -562,11 +556,9 @@ sys_telnet_init(void)
 
 setconnmode(0);
 
-NetNonblockingIO(net, 1);
-
-
-if (SetSockOpt(net, SOL_SOCKET, SO_OOBINLINE, 1) == -1) {
-	perror("SetSockOpt");
+ioctl(net, FIONBIO, );
+if (setsockopt(net, SOL_SOCKET, SO_OOBINLINE, , sizeof(one)) == -1) {
+	perror("setsockopt");
 }
 }
 



CVS commit: src/usr.bin/telnet

2018-12-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 09:20:05 UTC 2018

Modified Files:
src/usr.bin/telnet: sys_bsd.c

Log Message:
Expand SIG_FUNC_RET -from openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/telnet/sys_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/sys_bsd.c
diff -u src/usr.bin/telnet/sys_bsd.c:1.36 src/usr.bin/telnet/sys_bsd.c:1.37
--- src/usr.bin/telnet/sys_bsd.c:1.36	Thu Dec 13 05:22:14 2018
+++ src/usr.bin/telnet/sys_bsd.c	Thu Dec 13 09:20:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_bsd.c,v 1.36 2018/12/13 05:22:14 maya Exp $	*/
+/*	$NetBSD: sys_bsd.c,v 1.37 2018/12/13 09:20:05 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 from: static char sccsid[] = "@(#)sys_bsd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_bsd.c,v 1.36 2018/12/13 05:22:14 maya Exp $");
+__RCSID("$NetBSD: sys_bsd.c,v 1.37 2018/12/13 09:20:05 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,14 +60,12 @@ __RCSID("$NetBSD: sys_bsd.c,v 1.36 2018/
 #include "externs.h"
 #include "types.h"
 
-#define	SIG_FUNC_RET	void
+void susp(int);
+void ayt(int);
 
-SIG_FUNC_RET susp(int);
-SIG_FUNC_RET ayt(int);
-
-SIG_FUNC_RET intr(int);
-SIG_FUNC_RET intr2(int);
-SIG_FUNC_RET sendwin(int);
+void intr(int);
+void intr2(int);
+void sendwin(int);
 
 
 int
@@ -496,7 +494,7 @@ NetNonblockingIO(int fd, int onoff)
  */
 
 /* ARGSUSED */
-SIG_FUNC_RET
+void
 intr(int sig)
 {
 if (localchars) {
@@ -508,7 +506,7 @@ intr(int sig)
 }
 
 /* ARGSUSED */
-SIG_FUNC_RET
+void
 intr2(int sig)
 {
 if (localchars) {
@@ -523,7 +521,7 @@ intr2(int sig)
 }
 
 /* ARGSUSED */
-SIG_FUNC_RET
+void
 susp(int sig)
 {
 if ((rlogin != _POSIX_VDISABLE) && rlogin_susp())
@@ -533,7 +531,7 @@ susp(int sig)
 }
 
 /* ARGSUSED */
-SIG_FUNC_RET
+void
 sendwin(int sig)
 {
 if (connected) {
@@ -542,7 +540,7 @@ sendwin(int sig)
 }
 
 /* ARGSUSED */
-SIG_FUNC_RET
+void
 ayt(int sig)
 {
 if (connected)



CVS commit: src/usr.bin/telnet

2018-12-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 09:07:53 UTC 2018

Modified Files:
src/usr.bin/telnet: ring.c ring.h

Log Message:
Remove unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/telnet/ring.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/telnet/ring.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/ring.c
diff -u src/usr.bin/telnet/ring.c:1.13 src/usr.bin/telnet/ring.c:1.14
--- src/usr.bin/telnet/ring.c:1.13	Thu Aug  7 11:16:10 2003
+++ src/usr.bin/telnet/ring.c	Thu Dec 13 09:07:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ring.c,v 1.13 2003/08/07 11:16:10 agc Exp $	*/
+/*	$NetBSD: ring.c,v 1.14 2018/12/13 09:07:53 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)ring.c	8.2 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: ring.c,v 1.13 2003/08/07 11:16:10 agc Exp $");
+__RCSID("$NetBSD: ring.c,v 1.14 2018/12/13 09:07:53 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -284,26 +284,6 @@ ring_supply_data(Ring *ring, unsigned ch
 }
 }
 
-#ifdef notdef
-
-/*
- * Move data from the "consume" portion of the ring buffer
- */
-void
-ring_consume_data(Ring *ring, unsigned char *buffer, int count)
-{
-int i;
-
-while (count) {
-	i = MIN(count, ring_full_consecutive(ring));
-	memmove(buffer, ring->consume, i);
-	ring_consumed(ring, i);
-	count -= i;
-	buffer += i;
-}
-}
-#endif
-
 #ifdef	ENCRYPTION
 void
 ring_encrypt(Ring *ring, void (*encryptor)(unsigned char *, int))

Index: src/usr.bin/telnet/ring.h
diff -u src/usr.bin/telnet/ring.h:1.10 src/usr.bin/telnet/ring.h:1.11
--- src/usr.bin/telnet/ring.h:1.10	Thu Aug  7 11:16:10 2003
+++ src/usr.bin/telnet/ring.h	Thu Dec 13 09:07:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ring.h,v 1.10 2003/08/07 11:16:10 agc Exp $	*/
+/*	$NetBSD: ring.h,v 1.11 2018/12/13 09:07:53 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -75,10 +75,6 @@ extern int
 /* Data movement routines */
 extern void
 	ring_supply_data(Ring *ring, unsigned char *buffer, int count);
-#ifdef notdef
-extern void
-	ring_consume_data(Ring *ring, unsigned char *buffer, int count);
-#endif
 
 /* Buffer state transition routines */
 extern void



CVS commit: src/usr.bin/telnet

2018-12-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 05:22:15 UTC 2018

Modified Files:
src/usr.bin/telnet: externs.h sys_bsd.c telnet.c types.h

Log Message:
Remove unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/telnet/sys_bsd.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/telnet/types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/externs.h
diff -u src/usr.bin/telnet/externs.h:1.40 src/usr.bin/telnet/externs.h:1.41
--- src/usr.bin/telnet/externs.h:1.40	Thu Dec 13 05:07:03 2018
+++ src/usr.bin/telnet/externs.h	Thu Dec 13 05:22:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.40 2018/12/13 05:07:03 maya Exp $	*/
+/*	$NetBSD: externs.h,v 1.41 2018/12/13 05:22:14 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -247,7 +247,6 @@ void TerminalFlushOutput(void);
 void TerminalSaveState(void);
 cc_t *tcval(int);
 void TerminalDefaultChars(void);
-void TerminalRestoreState(void);
 void TerminalNewMode(int);
 void TerminalSpeeds(long *, long *);
 int TerminalWindowSize(long *, long *);

Index: src/usr.bin/telnet/sys_bsd.c
diff -u src/usr.bin/telnet/sys_bsd.c:1.35 src/usr.bin/telnet/sys_bsd.c:1.36
--- src/usr.bin/telnet/sys_bsd.c:1.35	Thu Dec 13 04:49:19 2018
+++ src/usr.bin/telnet/sys_bsd.c	Thu Dec 13 05:22:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_bsd.c,v 1.35 2018/12/13 04:49:19 maya Exp $	*/
+/*	$NetBSD: sys_bsd.c,v 1.36 2018/12/13 05:22:14 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 from: static char sccsid[] = "@(#)sys_bsd.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: sys_bsd.c,v 1.35 2018/12/13 04:49:19 maya Exp $");
+__RCSID("$NetBSD: sys_bsd.c,v 1.36 2018/12/13 05:22:14 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -243,13 +243,6 @@ TerminalDefaultChars(void)
 memmove(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
 }
 
-#ifdef notdef
-void
-TerminalRestoreState(void)
-{
-}
-#endif
-
 /*
  * TerminalNewMode - set up terminal to a specific mode.
  *	MODE_ECHO: do local terminal echo

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.38 src/usr.bin/telnet/telnet.c:1.39
--- src/usr.bin/telnet/telnet.c:1.38	Thu Dec 13 04:49:19 2018
+++ src/usr.bin/telnet/telnet.c	Thu Dec 13 05:22:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.38 2018/12/13 04:49:19 maya Exp $	*/
+/*	$NetBSD: telnet.c,v 1.39 2018/12/13 05:22:14 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.38 2018/12/13 04:49:19 maya Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.39 2018/12/13 05:22:14 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -162,18 +162,6 @@ static void doflush(void);
  */
 
 Clocks clocks;
-
-#ifdef	notdef
-Modelist modelist[] = {
-	{ "telnet command mode", COMMAND_LINE },
-	{ "character-at-a-time mode", 0 },
-	{ "character-at-a-time mode (local echo)", LOCAL_ECHO|LOCAL_CHARS },
-	{ "line-by-line mode (remote echo)", LINE | LOCAL_CHARS },
-	{ "line-by-line mode", LINE | LOCAL_ECHO | LOCAL_CHARS },
-	{ "line-by-line mode (local echoing suppressed)", LINE | LOCAL_CHARS },
-	{ "3270 mode", 0 },
-};
-#endif
 
 
 /*

Index: src/usr.bin/telnet/types.h
diff -u src/usr.bin/telnet/types.h:1.6 src/usr.bin/telnet/types.h:1.7
--- src/usr.bin/telnet/types.h:1.6	Thu Aug  7 11:16:12 2003
+++ src/usr.bin/telnet/types.h	Thu Dec 13 05:22:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.6 2003/08/07 11:16:12 agc Exp $	*/
+/*	$NetBSD: types.h,v 1.7 2018/12/13 05:22:14 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -32,13 +32,6 @@
  */
 
 typedef struct {
-char *modedescriptions;
-char modetype;
-} Modelist;
-
-extern Modelist modelist[];
-
-typedef struct {
 int
 	system,			/* what the current time is */
 	echotoggle,		/* last time user entered echo character */



CVS commit: src/usr.bin/telnet

2018-12-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 05:15:11 UTC 2018

Modified Files:
src/usr.bin/telnet: utilities.c

Log Message:
ExitString is used for error exit, do the minimum necessary here.
Avoid infinite loop:
telrcv->suboption->ExitString->SetForExit->telrcv

Reported by hacker fantastic, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/utilities.c
diff -u src/usr.bin/telnet/utilities.c:1.26 src/usr.bin/telnet/utilities.c:1.27
--- src/usr.bin/telnet/utilities.c:1.26	Thu Dec 13 05:07:03 2018
+++ src/usr.bin/telnet/utilities.c	Thu Dec 13 05:15:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.26 2018/12/13 05:07:03 maya Exp $	*/
+/*	$NetBSD: utilities.c,v 1.27 2018/12/13 05:15:11 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.26 2018/12/13 05:07:03 maya Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.27 2018/12/13 05:15:11 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -907,7 +907,6 @@ Exit(int returnCode)
 void
 ExitString(const char *string, int returnCode)
 {
-SetForExit();
 fwrite(string, 1, strlen(string), stderr);
 exit(returnCode);
 }



CVS commit: src/usr.bin/telnet

2018-12-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 05:07:03 UTC 2018

Modified Files:
src/usr.bin/telnet: externs.h utilities.c

Log Message:
static-ify.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/externs.h
diff -u src/usr.bin/telnet/externs.h:1.39 src/usr.bin/telnet/externs.h:1.40
--- src/usr.bin/telnet/externs.h:1.39	Thu Dec 13 04:49:19 2018
+++ src/usr.bin/telnet/externs.h	Thu Dec 13 05:07:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.39 2018/12/13 04:49:19 maya Exp $	*/
+/*	$NetBSD: externs.h,v 1.40 2018/12/13 05:07:03 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -328,7 +328,6 @@ void printoption(const char *, int, int 
 void optionstatus(void);
 void printsub(int, unsigned char *, int);
 void EmptyTerminal(void);
-void SetForExit(void);
 void Exit(int) __attribute__((__noreturn__));
 void ExitString(const char *, int) __attribute__((__noreturn__));
 

Index: src/usr.bin/telnet/utilities.c
diff -u src/usr.bin/telnet/utilities.c:1.25 src/usr.bin/telnet/utilities.c:1.26
--- src/usr.bin/telnet/utilities.c:1.25	Thu Dec 13 04:49:19 2018
+++ src/usr.bin/telnet/utilities.c	Thu Dec 13 05:07:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.25 2018/12/13 04:49:19 maya Exp $	*/
+/*	$NetBSD: utilities.c,v 1.26 2018/12/13 05:07:03 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.25 2018/12/13 04:49:19 maya Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.26 2018/12/13 05:07:03 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -63,6 +63,8 @@ __RCSID("$NetBSD: utilities.c,v 1.25 201
 #include 
 #endif
 
+static void SetForExit(void);
+
 FILE	*NetTrace = 0;		/* Not in bss, since needs to stay */
 int	prettydump;
 
@@ -879,7 +881,7 @@ EmptyTerminal(void)
 }
 }
 
-void
+static void
 SetForExit(void)
 {
 setconnmode(0);



CVS commit: src/usr.bin/telnet

2018-12-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 13 04:49:19 UTC 2018

Modified Files:
src/usr.bin/telnet: Makefile commands.c defines.h externs.h main.c
sys_bsd.c telnet.c utilities.c
Removed Files:
src/usr.bin/telnet: tn3270.c

Log Message:
unifdef TN3270 which is never defined (and wouldn't build if it was)
delete tn3270 file no longer needed.
SetIn3270(); expands to nothing now, so remove it.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/telnet/Makefile
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/telnet/commands.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/telnet/defines.h
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/telnet/main.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/telnet/sys_bsd.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.22 -r0 src/usr.bin/telnet/tn3270.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.53 src/usr.bin/telnet/Makefile:1.54
--- src/usr.bin/telnet/Makefile:1.53	Sun Feb 25 00:16:49 2018
+++ src/usr.bin/telnet/Makefile	Thu Dec 13 04:49:19 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.53 2018/02/25 00:16:49 mrg Exp $
+#	$NetBSD: Makefile,v 1.54 2018/12/13 04:49:19 maya Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -50,7 +50,7 @@ LDADD+= -lterminfo ${LIBTELNETDIR}/libte
 DPADD+=	${LIBTERMINFO} ${LIBTELNETDIR}/libtelnet.a
 
 SRCS=	authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \
-	terminal.c tn3270.c utilities.c
+	terminal.c utilities.c
 
 CPPFLAGS+=-I${NETBSDSRCDIR}/lib
 CPPFLAGS+=-DIPSEC

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.70 src/usr.bin/telnet/commands.c:1.71
--- src/usr.bin/telnet/commands.c:1.70	Tue Oct  4 14:36:11 2016
+++ src/usr.bin/telnet/commands.c	Thu Dec 13 04:49:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.70 2016/10/04 14:36:11 joerg Exp $	*/
+/*	$NetBSD: commands.c,v 1.71 2018/12/13 04:49:19 maya Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.70 2016/10/04 14:36:11 joerg Exp $");
+__RCSID("$NetBSD: commands.c,v 1.71 2018/12/13 04:49:19 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -160,9 +160,6 @@ static struct envlist *getenvcmd(char *)
 #ifdef AUTHENTICATION
 static int auth_help(char *);
 #endif
-#ifdef TN3270
-static void filestuff(int);
-#endif
 static int status(int, char *[]);
 static const char *sockaddr_ntop (struct sockaddr *);
 typedef int (*intrtn_t)(int, char **);
@@ -743,18 +740,6 @@ static struct togglelist Togglelist[] = 
 		,
 		"recognize certain control characters" },
 { " ", "", 0, NULL, NULL },		/* empty line */
-#ifdef TN3270
-{ "apitrace",
-	"(debugging) toggle tracing of API transactions",
-	0,
-		,
-		"trace API transactions" },
-{ "cursesdata",
-	"(debugging) toggle printing of hexadecimal curses data",
-	0,
-		,
-		"print hexadecimal representation of curses data" },
-#endif	/* defined(TN3270) */
 { "debug",
 	"debugging",
 	togdebug,
@@ -1355,7 +1340,6 @@ suspend(int argc, char *argv[])
 return 1;
 }
 
-#ifndef TN3270
 /*ARGSUSED*/
 int
 shell(int argc, char *argv[])
@@ -1403,7 +1387,6 @@ shell(int argc, char *argv[])
 }
 return 1;
 }
-#endif	/* !defined(TN3270) */
 
 /*VARARGS*/
 static int
@@ -1422,9 +1405,6 @@ bye(int  argc, char *argv[])
 #endif	/* defined(AUTHENTICATION) */
 	/* reset options */
 	tninit();
-#ifdef TN3270
-	SetIn3270();		/* Get out of 3270 mode */
-#endif	/* defined(TN3270) */
 }
 if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0)) {
 	longjmp(toplevel, 1);
@@ -2035,35 +2015,6 @@ encrypt_cmd(int argc, char *argv[])
 }
 #endif	/* ENCRYPTION */
 
-#ifdef TN3270
-static void
-filestuff(int fd)
-{
-int res;
-
-setconnmode(0);
-res = fcntl(fd, F_GETOWN, 0);
-setcommandmode();
-
-if (res == -1) {
-	perror("fcntl");
-	return;
-}
-printf("\tOwner is %d.\n", res);
-
-setconnmode(0);
-res = fcntl(fd, F_GETFL, 0);
-setcommandmode();
-
-if (res == -1) {
-	perror("fcntl");
-	return;
-}
-#ifdef notdef
-printf("\tFlags are 0x%x: %s\n", res, decodeflags(res));
-#endif
-}
-#endif /* defined(TN3270) */
 
 /*
  * Print status about the connection.
@@ -2102,35 +2053,8 @@ status(int argc, char *argv[])
 } else {
 	printf("No connection.\n");
 }
-#   ifndef TN3270
 printf("Escape character is '%s'.\n", control(escape));
 (void) fflush(stdout);
-#   else /* !defined(TN3270) */
-if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) {
-	printf("Escape character is 

CVS commit: src/usr.bin/telnet

2018-12-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Dec 12 19:05:32 UTC 2018

Modified Files:
src/usr.bin/telnet: telnet.c utilities.c

Log Message:
switch sprintf to snprintf in places.

Reported by hacker fantastic, thanks!

ok xtos.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.36 src/usr.bin/telnet/telnet.c:1.37
--- src/usr.bin/telnet/telnet.c:1.36	Tue Jan 10 13:49:32 2012
+++ src/usr.bin/telnet/telnet.c	Wed Dec 12 19:05:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $	*/
+/*	$NetBSD: telnet.c,v 1.37 2018/12/12 19:05:32 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.37 2018/12/12 19:05:32 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -856,8 +856,8 @@ suboption(void)
 	name = gettermname();
 	len = strlen(name) + 4 + 2;
 	if (len < NETROOM()) {
-		sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
-TELQUAL_IS, name, IAC, SE);
+		snprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
+TELOPT_TTYPE, TELQUAL_IS, name, IAC, SE);
 		ring_supply_data(, temp, len);
 		printsub('>', [2], len-2);
 	} else {
@@ -878,8 +878,8 @@ suboption(void)
 
 	TerminalSpeeds(, );
 
-	sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED,
-		TELQUAL_IS, osp, isp, IAC, SE);
+	snprintf((char *)temp, sizeof(temp), "%c%c%c%c%ld,%ld%c%c", IAC, SB,
+		TELOPT_TSPEED, TELQUAL_IS, osp, isp, IAC, SE);
 	len = strlen((char *)temp+4) + 4;	/* temp[3] is 0 ... */
 
 	if (len < NETROOM()) {
@@ -983,8 +983,8 @@ suboption(void)
 		send_wont(TELOPT_XDISPLOC, 1);
 		break;
 	}
-	sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC,
-		TELQUAL_IS, dp, IAC, SE);
+	snprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
+		TELOPT_XDISPLOC, TELQUAL_IS, dp, IAC, SE);
 	len = strlen((char *)temp+4) + 4;	/* temp[3] is 0 ... */
 
 	if (len < NETROOM()) {

Index: src/usr.bin/telnet/utilities.c
diff -u src/usr.bin/telnet/utilities.c:1.23 src/usr.bin/telnet/utilities.c:1.24
--- src/usr.bin/telnet/utilities.c:1.23	Mon Jan  9 16:08:55 2012
+++ src/usr.bin/telnet/utilities.c	Wed Dec 12 19:05:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.23 2012/01/09 16:08:55 christos Exp $	*/
+/*	$NetBSD: utilities.c,v 1.24 2018/12/12 19:05:32 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.23 2012/01/09 16:08:55 christos Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.24 2018/12/12 19:05:32 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -633,7 +633,7 @@ printsub(
 		}
 		{
 		char tbuf[64];
-		sprintf(tbuf, "%s%s%s%s%s",
+		snprintf(tbuf, sizeof(tbuf), "%s%s%s%s%s",
 			pointer[2]_EDIT ? "|EDIT" : "",
 			pointer[2]_TRAPSIG ? "|TRAPSIG" : "",
 			pointer[2]_SOFT_TAB ? "|SOFT_TAB" : "",



CVS commit: src/usr.bin/telnet

2017-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 28 23:45:53 UTC 2017

Modified Files:
src/usr.bin/telnet: Makefile

Log Message:
add sqlite3


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/telnet/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.50 src/usr.bin/telnet/Makefile:1.51
--- src/usr.bin/telnet/Makefile:1.50	Fri Aug 10 08:10:27 2012
+++ src/usr.bin/telnet/Makefile	Sat Jan 28 18:45:53 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.50 2012/08/10 12:10:27 joerg Exp $
+#	$NetBSD: Makefile,v 1.51 2017/01/28 23:45:53 christos Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -65,8 +65,8 @@ LIBTELNETDIR!=	cd ${.CURDIR}/../../lib/l
 
 .if (${USE_KERBEROS} != "no")
 CPPFLAGS+=-DKRB5 -DFORWARD
-LDADD+= -lkrb5 -lasn1 -lcom_err -lroken
-DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN}
+LDADD+= -lkrb5 -lasn1 -lcom_err -lroken -lsqlite3
+DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN} ${LIBSQLITE3}
 .endif
 
 .if (${MKCRYPTO} != "no")



CVS commit: src/usr.bin/telnet

2016-10-04 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Oct  4 14:36:11 UTC 2016

Modified Files:
src/usr.bin/telnet: commands.c

Log Message:
GC header left from earlier diagnostic test.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/telnet/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.69 src/usr.bin/telnet/commands.c:1.70
--- src/usr.bin/telnet/commands.c:1.69	Tue Oct  4 14:35:38 2016
+++ src/usr.bin/telnet/commands.c	Tue Oct  4 14:36:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.69 2016/10/04 14:35:38 joerg Exp $	*/
+/*	$NetBSD: commands.c,v 1.70 2016/10/04 14:36:11 joerg Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.69 2016/10/04 14:35:38 joerg Exp $");
+__RCSID("$NetBSD: commands.c,v 1.70 2016/10/04 14:36:11 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,7 +75,6 @@ __RCSID("$NetBSD: commands.c,v 1.69 2016
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/usr.bin/telnet

2016-10-04 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Oct  4 14:35:39 UTC 2016

Modified Files:
src/usr.bin/telnet: commands.c externs.h

Log Message:
Remove source routing support.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/telnet/commands.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/telnet/externs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.68 src/usr.bin/telnet/commands.c:1.69
--- src/usr.bin/telnet/commands.c:1.68	Mon Jan  9 16:08:55 2012
+++ src/usr.bin/telnet/commands.c	Tue Oct  4 14:35:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $	*/
+/*	$NetBSD: commands.c,v 1.69 2016/10/04 14:35:38 joerg Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c	8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $");
+__RCSID("$NetBSD: commands.c,v 1.69 2016/10/04 14:35:38 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,6 +75,7 @@ __RCSID("$NetBSD: commands.c,v 1.68 2012
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2192,11 +2193,6 @@ tn(int argc, char *argv[])
 struct addrinfo hints, *res, *res0;
 const char *cause = "telnet: unknown";
 int error;
-#if	defined(IP_OPTIONS) && defined(IPPROTO_IP)
-char *srp = 0;
-long srlen;
-int proto, opt;
-#endif
 char *cmd, *hostp = 0;
 const char *portp = 0;
 const char *user = 0;
@@ -2249,20 +2245,7 @@ tn(int argc, char *argv[])
 	goto usage;
 
 (void) strlcpy(_hostname, hostp, sizeof(_hostname));
-if (hostp[0] == '@' || hostp[0] == '!') {
-	char *p;
-	hostname = NULL;
-	for (p = hostp + 1; *p; p++) {
-	if (*p == ',' || *p == '@')
-		hostname = p;
-	}
-	if (hostname == NULL) {
-	fprintf(stderr, "%s: bad source route specification\n", hostp);
-	return 0;
-	}
-	*hostname++ = '\0';
-} else
-	hostname = hostp;
+hostname = hostp;
 
 if (!portp) {
 	telnetport = 1;
@@ -2322,15 +2305,6 @@ tn(int argc, char *argv[])
 	if (telnet_debug && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) {
 	perror("setsockopt (SO_DEBUG)");
 	}
-	if (hostp[0] == '@' || hostp[0] == '!') {
-	if ((srlen = sourceroute(res, hostp, , , )) < 0) {
-		(void) NetClose(net);
-		net = -1;
-		continue;
-	}
-	if (srp && setsockopt(net, proto, opt, srp, srlen) < 0)
-		perror("setsockopt (source route)");
-	}
 
 #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
 	if (setpolicy(net, res, ipsec_policy_in) < 0) {
@@ -2692,216 +2666,3 @@ cmdrc(const char *m1, const char *m2)
 }
 fclose(rcfile);
 }
-
-/*
- * Source route is handed in as
- *	[!]@hop1@hop2...@dst
- *
- * If the leading ! is present, it is a strict source route, otherwise it is
- * assmed to be a loose source route.  Note that leading ! is effective
- * only for IPv4 case.
- *
- * We fill in the source route option as
- *	hop1,hop2,hop3...dest
- * and return a pointer to hop1, which will
- * be the address to connect() to.
- *
- * Arguments:
- *	ai:	The address (by struct addrinfo) for the final destination.
- *
- *	arg:	Pointer to route list to decipher
- *
- *	cpp: 	Pointer to a pointer, so that sourceroute() can return
- *		the address of result buffer (statically alloc'ed).
- *
- *	protop/optp:
- *		Pointer to an integer.  The pointed variable
- *	lenp:	pointer to an integer that contains the
- *		length of *cpp if *cpp != NULL.
- *
- * Return values:
- *
- *	Returns the length of the option pointed to by *cpp.  If the
- *	return value is -1, there was a syntax error in the
- *	option, either arg contained unknown characters or too many hosts,
- *	or hostname cannot be resolved.
- *
- *	The caller needs to pass return value (len), *cpp, *protop and *optp
- *	to setsockopt(2).
- *
- *	*cpp:	Points to the result buffer.  The region is statically
- *		allocated by the function.
- *
- *	*protop:
- *		protocol # to be passed to setsockopt(2).
- *
- *	*optp:	option # to be passed to setsockopt(2).
- *
- */
-int
-sourceroute(struct addrinfo *ai, char *arg, char **cpp, int *protop, int *optp)
-{
-	char *cp, *cp2, *lsrp, *lsrep;
-	struct addrinfo hints, *res;
-	int len, error;
-	struct sockaddr_in *sin;
-	char c;
-	static char lsr[44];
-#ifdef INET6
-	struct cmsghdr *cmsg;
-	struct sockaddr_in6 *sin6;
-	static char rhbuf[1024];
-#endif
-
-	/*
-	 * Verify the arguments.
-	 */
-	if (cpp == NULL)
-		return -1;
-
-	cp = arg;
-
-	*cpp = NULL;
-
-	  /* init these just in case */
-	lsrp = NULL;
-	lsrep = NULL;
-#ifdef INET6
-	cmsg = NULL;
-#endif
-	
-	switch (ai->ai_family) {
-	case AF_INET:
-		lsrp = lsr;
-		lsrep = lsrp + sizeof(lsr);
-
-		/*
-		 * Next, decide whether we have a loose source
-		 * route or a strict source route, and fill in
-		 * the begining of the option.
-		 

CVS commit: src/usr.bin/telnet

2012-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 13:49:32 UTC 2012

Modified Files:
src/usr.bin/telnet: telnet.c

Log Message:
fix signed/unsigned comparison.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/telnet/telnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.35 src/usr.bin/telnet/telnet.c:1.36
--- src/usr.bin/telnet/telnet.c:1.35	Mon Jan  9 11:08:55 2012
+++ src/usr.bin/telnet/telnet.c	Tue Jan 10 08:49:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.35 2012/01/09 16:08:55 christos Exp $	*/
+/*	$NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)telnet.c	8.4 (Berkeley) 5/30/95;
 #else
-__RCSID($NetBSD: telnet.c,v 1.35 2012/01/09 16:08:55 christos Exp $);
+__RCSID($NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -1633,7 +1633,7 @@ env_opt_add(unsigned char *ep)
 	vp = env_getvalue(ep);
 	elen = 2 * (vp ? strlen((char *)vp) : 0) +
 		2 * strlen((char *)ep) + 6;
-	if ((opt_replyend - opt_replyp)  elen)
+	if ((unsigned int)(opt_replyend - opt_replyp)  elen)
 	{
 		unsigned char *p;
 		len = opt_replyend - opt_reply + elen;



CVS commit: src/usr.bin/telnet

2012-01-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan  9 16:08:56 UTC 2012

Modified Files:
src/usr.bin/telnet: Makefile authenc.c commands.c externs.h main.c
sys_bsd.c telnet.c utilities.c

Log Message:
PR/45805: Borodin Oleg: telnet/telnetd with -DAUTHENTICATION -DENCRYPTION
(rfc2941)
- Minimal diffs to separate MKCRYPTO from USE_KERBEROS


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/telnet/Makefile
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/telnet/authenc.c
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/telnet/commands.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/telnet/externs.h
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/telnet/main.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/telnet/sys_bsd.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/telnet/telnet.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/telnet/utilities.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.48 src/usr.bin/telnet/Makefile:1.49
--- src/usr.bin/telnet/Makefile:1.48	Wed Oct  5 06:48:54 2011
+++ src/usr.bin/telnet/Makefile	Mon Jan  9 11:08:55 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.48 2011/10/05 10:48:54 roy Exp $
+#	$NetBSD: Makefile,v 1.49 2012/01/09 16:08:55 christos Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -34,7 +34,7 @@
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 #
 
-WARNS?=	1	# XXX -Wshadow etc.  fix asap
+WARNS?=	4	# XXX -Wshadow etc.  fix asap
 CWARNFLAGS.clang+=	-Wno-tautological-compare -Wno-format-security
 
 .include bsd.own.mk
@@ -64,19 +64,22 @@ CPPFLAGS+=-DINET6
 LIBTELNETDIR!=	cd ${.CURDIR}/../../lib/libtelnet; ${PRINTOBJDIR}
 
 .if (${USE_KERBEROS} != no)
-CPPFLAGS+=-DKRB5 -DFORWARD -DAUTHENTICATION -DENCRYPTION
-LDADD+= -lkrb5 -lasn1 -lcrypto -lcrypt
-DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT}
+CPPFLAGS+=-DKRB5 -DFORWARD
+LDADD+= -lkrb5 -lasn1 -lcom_err -lroken
+DPADD+=	${LIBKRB5} ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN}
+.endif
+
+.if (${MKCRYPTO} != no)
+CPPFLAGS+=-DAUTHENTICATION -DENCRYPTION
+LDADD+= -ldes -lcrypto -lcrypt
+DPADD+=	${LIBDES} ${LIBCRYPTO} ${LIBCRYPT}
+.endif
 
 .if (${USE_PAM} != no)
 LDADD+= -lpam ${PAM_STATIC_LDADD}
 DPADD+=	${LIBPAM} ${PAM_STATIC_DPADD}
 .endif
 
-LDADD+= -ldes -lcom_err -lroken
-DPADD+=	${LIBDES} ${LIBCOM_ERR} ${LIBROKEN}
-.endif
-
 .if defined(HAVE_GCC) || defined(HAVE_PCC)
 .for f in commands telnet terminal utilities
 COPTS.${f}.c+=  -Wno-pointer-sign

Index: src/usr.bin/telnet/authenc.c
diff -u src/usr.bin/telnet/authenc.c:1.12 src/usr.bin/telnet/authenc.c:1.13
--- src/usr.bin/telnet/authenc.c:1.12	Thu Aug  7 07:16:07 2003
+++ src/usr.bin/telnet/authenc.c	Mon Jan  9 11:08:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: authenc.c,v 1.12 2003/08/07 11:16:07 agc Exp $	*/
+/*	$NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)authenc.c	8.1 (Berkeley) 6/6/93;
 #else
-__RCSID($NetBSD: authenc.c,v 1.12 2003/08/07 11:16:07 agc Exp $);
+__RCSID($NetBSD: authenc.c,v 1.13 2012/01/09 16:08:55 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -87,7 +87,7 @@ telnet_getenv(char *val)
 }
 
 char *
-telnet_gets(char *prompt, char *result, int length, int echo)
+telnet_gets(char *prmpt, char *result, int length, int echo)
 {
 	extern int globalmode;
 	int om = globalmode;
@@ -95,9 +95,9 @@ telnet_gets(char *prompt, char *result, 
 
 	TerminalNewMode(-1);
 	if (echo) {
-		printf(%s, prompt);
+		printf(%s, prmpt);
 		res = fgets(result, length, stdin);
-	} else if ((res = getpass(prompt)) != NULL) {
+	} else if ((res = getpass(prmpt)) != NULL) {
 		strlcpy(result, res, length);
 		res = result;
 	}

Index: src/usr.bin/telnet/commands.c
diff -u src/usr.bin/telnet/commands.c:1.67 src/usr.bin/telnet/commands.c:1.68
--- src/usr.bin/telnet/commands.c:1.67	Mon Dec 18 09:18:40 2006
+++ src/usr.bin/telnet/commands.c	Mon Jan  9 11:08:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.67 2006/12/18 14:18:40 christos Exp $	*/
+/*	$NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $	*/
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = @(#)commands.c	8.4 (Berkeley) 5/30/95;
 #else
-__RCSID($NetBSD: commands.c,v 1.67 2006/12/18 14:18:40 christos Exp $);
+__RCSID($NetBSD: commands.c,v 1.68 2012/01/09 16:08:55 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -109,8 +109,8 @@ char	*hostname;
 static char _hostname[MAXHOSTNAMELEN];
 
 typedef struct {
-	char	*name;		/* command name */
-	char	*help;		/* help string (NULL for no help) */
+	const char	*name;	/* command name */
+	const char	*help;	/* help string (NULL for no help) */
 	int	(*handler)	/* routine which executes command */
 			(int, char *[]);
 	int	needconnect;	/* Do we need to be connected to execute? */
@@ -123,7 +123,7 @@ static 

CVS commit: src/usr.bin/telnet

2011-10-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct  7 10:14:22 UTC 2011

Modified Files:
src/usr.bin/telnet: telnet.c

Log Message:
Simplify


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/telnet/telnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.32 src/usr.bin/telnet/telnet.c:1.33
--- src/usr.bin/telnet/telnet.c:1.32	Wed Oct  5 10:48:54 2011
+++ src/usr.bin/telnet/telnet.c	Fri Oct  7 10:14:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.32 2011/10/05 10:48:54 roy Exp $	*/
+/*	$NetBSD: telnet.c,v 1.33 2011/10/07 10:14:22 joerg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)telnet.c	8.4 (Berkeley) 5/30/95;
 #else
-__RCSID($NetBSD: telnet.c,v 1.32 2011/10/05 10:48:54 roy Exp $);
+__RCSID($NetBSD: telnet.c,v 1.33 2011/10/07 10:14:22 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -753,6 +753,7 @@ setupterm(char *tname, int fd, int *errp
 {
 	char zz[1024], *zz_ptr;
 	char *ext_tc, *newptr;
+	size_t len;
 	
 	if ((termbuf = (char *) malloc(1024)) == NULL)
 		goto error;
@@ -763,13 +764,13 @@ setupterm(char *tname, int fd, int *errp
 		if (tgetstr(ZZ, zz_ptr) != NULL) {
 			  /* it was, fish back the full termcap */
 			sscanf(zz, %p, ext_tc);
-			if ((newptr = (char *) realloc(termbuf,
-		   strlen(ext_tc) + 1))
+			len = strlen(ext_tc) + 1;
+			if ((newptr = (char *) realloc(termbuf, len))
 			== NULL) {
 goto error;
 			}
 
-			strlcpy(newptr, ext_tc, strlen(ext_tc) + 1);
+			memcpy(newptr, ext_tc, len);
 			termbuf = newptr;
 		}
 



CVS commit: src/usr.bin/telnet

2011-10-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  7 16:30:17 UTC 2011

Modified Files:
src/usr.bin/telnet: telnet.c

Log Message:
remove casts


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/telnet/telnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.33 src/usr.bin/telnet/telnet.c:1.34
--- src/usr.bin/telnet/telnet.c:1.33	Fri Oct  7 06:14:22 2011
+++ src/usr.bin/telnet/telnet.c	Fri Oct  7 12:30:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.33 2011/10/07 10:14:22 joerg Exp $	*/
+/*	$NetBSD: telnet.c,v 1.34 2011/10/07 16:30:17 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)telnet.c	8.4 (Berkeley) 5/30/95;
 #else
-__RCSID($NetBSD: telnet.c,v 1.33 2011/10/07 10:14:22 joerg Exp $);
+__RCSID($NetBSD: telnet.c,v 1.34 2011/10/07 16:30:17 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -755,20 +755,18 @@ setupterm(char *tname, int fd, int *errp
 	char *ext_tc, *newptr;
 	size_t len;
 	
-	if ((termbuf = (char *) malloc(1024)) == NULL)
+	if ((termbuf = malloc(1024)) == NULL)
 		goto error;
 	
 	if (tgetent(termbuf, tname) == 1) {
-		  /* check for ZZ capability, which indicates termcap truncated */
+		/* check for ZZ capability, indicating termcap truncated */
 		zz_ptr = zz;
 		if (tgetstr(ZZ, zz_ptr) != NULL) {
-			  /* it was, fish back the full termcap */
+			/* it was, fish back the full termcap */
 			sscanf(zz, %p, ext_tc);
 			len = strlen(ext_tc) + 1;
-			if ((newptr = (char *) realloc(termbuf, len))
-			== NULL) {
+			if ((newptr = realloc(termbuf, len)) == NULL)
 goto error;
-			}
 
 			memcpy(newptr, ext_tc, len);
 			termbuf = newptr;



CVS commit: src/usr.bin/telnet

2011-10-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Oct  5 10:48:54 UTC 2011

Modified Files:
src/usr.bin/telnet: Makefile telnet.c

Log Message:
Use terminfo and the non-standard ttytype rather than termcap.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/telnet/Makefile
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/telnet/telnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/telnet/Makefile
diff -u src/usr.bin/telnet/Makefile:1.47 src/usr.bin/telnet/Makefile:1.48
--- src/usr.bin/telnet/Makefile:1.47	Mon Jun 20 07:44:01 2011
+++ src/usr.bin/telnet/Makefile	Wed Oct  5 10:48:54 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.47 2011/06/20 07:44:01 mrg Exp $
+#	$NetBSD: Makefile,v 1.48 2011/10/05 10:48:54 roy Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -43,7 +43,7 @@ USE_FORT?= yes	# network client
 
 PROG=	telnet
 
-CPPFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -DENV_HACK
+CPPFLAGS+=-DKLUDGELINEMODE -DUSE_TERMIO -DENV_HACK
 CPPFLAGS+=-I${.CURDIR}
 
 LDADD+= -lterminfo ${LIBTELNETDIR}/libtelnet.a

Index: src/usr.bin/telnet/telnet.c
diff -u src/usr.bin/telnet/telnet.c:1.31 src/usr.bin/telnet/telnet.c:1.32
--- src/usr.bin/telnet/telnet.c:1.31	Thu Feb  2 19:33:12 2006
+++ src/usr.bin/telnet/telnet.c	Wed Oct  5 10:48:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: telnet.c,v 1.31 2006/02/02 19:33:12 he Exp $	*/
+/*	$NetBSD: telnet.c,v 1.32 2011/10/05 10:48:54 roy Exp $	*/
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,14 +34,14 @@
 #if 0
 static char sccsid[] = @(#)telnet.c	8.4 (Berkeley) 5/30/95;
 #else
-__RCSID($NetBSD: telnet.c,v 1.31 2006/02/02 19:33:12 he Exp $);
+__RCSID($NetBSD: telnet.c,v 1.32 2011/10/05 10:48:54 roy Exp $);
 #endif
 #endif /* not lint */
 
 #include sys/param.h
 
 #include signal.h
-#include termcap.h
+#include term.h
 #include unistd.h
 /* By the way, we need to include curses.h before telnet.h since,
  * among other things, telnet.h #defines 'DO', which is a variable
@@ -66,7 +66,6 @@ __RCSID($NetBSD: telnet.c,v 1.31 2006/0
 #include libtelnet/encrypt.h
 #endif
 
-
 #define	strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)0x7f) : (x))
 
 static unsigned char	subbuffer[SUBBUFSIZE],
@@ -750,7 +749,7 @@ char *termbuf;
 
 /*ARGSUSED*/
 int
-setup_term(char *tname, int fd, int *errp)
+setupterm(char *tname, int fd, int *errp)
 {
 	char zz[1024], *zz_ptr;
 	char *ext_tc, *newptr;
@@ -803,7 +802,7 @@ gettermname(void)
 		if (tnamep  tnamep != unknown)
 			free(tnamep);
 		if ((tname = (char *)env_getvalue((unsigned char *)TERM)) 
-(setup_term(tname, 1, err) == 0)) {
+(setupterm(tname, 1, err) == 0)) {
 			tnamep = mklist(termbuf, tname);
 		} else {
 			if (tname  ((int)strlen(tname) = 40)) {