[2241] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

krb5b7: telnet: tn() needs to stash args before calling cmdrc()

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Sep 17 17:14:36 1996

Date: Tue, 17 Sep 1996 17:14:33 -0400
From: "Jonathan I. Kamens" <jik@jik.tiac.net>
To: krb5-bugs@MIT.EDU, kerberos@MIT.EDU

The tn() function in telnet/commands.c needs to stash its arguments
before calling cmdrc() because that function can blow away the memory
in which tn()'s arguments were stored.

Here's a patch:

--- telnet/commands.c	1996/09/17 19:57:31	1.5
+++ telnet/commands.c	1996/09/17 19:58:25	1.6
@@ -2564,7 +2564,13 @@
 	auth_encrypt_connect(connected);
 #endif	/* defined(AUTHENTICATION) || defined(ENCRYPTION) */
     } while (connected == 0);
+    if (user)
+      user = strdup(user);
+    if (hostp)
+      hostp = strdup(hostp);
     cmdrc(hostp, hostname);
+    if (hostp)
+      free(hostp);
     if (autologin && user == NULL) {
 	struct passwd *pw;
 
@@ -2576,6 +2582,8 @@
 		else
 			user = NULL;
 	}
+	if (user)
+	  user = strdup(user);
     }
     if (user) {
 	env_define((unsigned char *)"USER", (unsigned char *)user);
@@ -2584,6 +2592,8 @@
     (void) call(status, "status", "notmuch", 0);
     if (setjmp(peerdied) == 0)
 	telnet(user);
+    if (user)
+      free(user);
     (void) NetClose(net);
     ExitString("Connection closed by foreign host.\r\n",1);
     /*NOTREACHED*/

home help back first fref pref prev next nref lref last post