Subject: libtelnet func signature change
To: None <tech-userlevel@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-userlevel
Date: 07/15/2003 14:26:59
	i would like to check in the following (changes function signature
	in libtelnet).  what should i do to shlib major/minor?

	i guess our life is much easier if we stop using libtelnet and compile
	them under libexec/telnetd and usr.bin/telnet...

itojun


Index: lib/libtelnet/auth-proto.h
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/auth-proto.h,v
retrieving revision 1.10
diff -u -r1.10 auth-proto.h
--- lib/libtelnet/auth-proto.h	2003/07/14 08:36:27	1.10
+++ lib/libtelnet/auth-proto.h	2003/07/15 05:25:39
@@ -81,7 +81,7 @@
 void auth_name __P((unsigned char *, int));
 int auth_sendname __P((unsigned char *, int));
 void auth_finished __P((Authenticator *, int));
-int auth_wait __P((char *));
+int auth_wait __P((char *, size_t));
 void auth_debug __P((int));
 void auth_printsub __P((unsigned char *, int, unsigned char *, int));
 
@@ -90,7 +90,7 @@
 int kerberos4_send __P((Authenticator *));
 void kerberos4_is __P((Authenticator *, unsigned char *, int));
 void kerberos4_reply __P((Authenticator *, unsigned char *, int));
-int kerberos4_status __P((Authenticator *, char *, int));
+int kerberos4_status __P((Authenticator *, char *, size_t, int));
 void kerberos4_printsub __P((unsigned char *, int, unsigned char *, int));
 #endif
 
@@ -99,7 +99,7 @@
 int kerberos5_send __P((Authenticator *));
 void kerberos5_is __P((Authenticator *, unsigned char *, int));
 void kerberos5_reply __P((Authenticator *, unsigned char *, int));
-int kerberos5_status __P((Authenticator *, char *, int));
+int kerberos5_status __P((Authenticator *, char *, size_t, int));
 void kerberos5_printsub __P((unsigned char *, int, unsigned char *, int));
 #endif
 #endif
Index: lib/libtelnet/auth.c
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/auth.c,v
retrieving revision 1.14
diff -u -r1.14 auth.c
--- lib/libtelnet/auth.c	2003/07/15 05:09:34	1.14
+++ lib/libtelnet/auth.c	2003/07/15 05:25:39
@@ -602,8 +602,9 @@
 }
 
 	int
-auth_wait(name)
+auth_wait(name, l)
 	char *name;
+	size_t l;
 {
 	if (auth_debug_mode)
 		printf(">>>%s: in auth_wait.\r\n", Name);
@@ -630,7 +631,7 @@
 
 	if (authenticated->status)
 		validuser = (*authenticated->status)(authenticated,
-						     name, validuser);
+						     name, l, validuser);
 	return(validuser);
 }
 
Index: lib/libtelnet/auth.h
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/auth.h,v
retrieving revision 1.8
diff -u -r1.8 auth.h
--- lib/libtelnet/auth.h	1999/09/12 19:37:48	1.8
+++ lib/libtelnet/auth.h	2003/07/15 05:25:39
@@ -71,7 +71,7 @@
 	int	(*send) __P((struct XauthP *));
 	void	(*is) __P((struct XauthP *, unsigned char *, int));
 	void	(*reply) __P((struct XauthP *, unsigned char *, int));
-	int	(*status) __P((struct XauthP *, char *, int));
+	int	(*status) __P((struct XauthP *, char *, size_t, int));
 	void	(*printsub) __P((unsigned char *, int, unsigned char *, int));
 } Authenticator;
 
Index: lib/libtelnet/kerberos.c
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/kerberos.c,v
retrieving revision 1.11
diff -u -r1.11 kerberos.c
--- lib/libtelnet/kerberos.c	2003/07/15 05:09:35	1.11
+++ lib/libtelnet/kerberos.c	2003/07/15 05:25:40
@@ -434,16 +434,17 @@
 }
 
 	int
-kerberos4_status(ap, kname, level)
+kerberos4_status(ap, kname, l, level)
 	Authenticator *ap;
 	char *kname;
+	size_t l;
 	int level;
 {
 	if (level < AUTH_USER)
 		return(level);
 
 	if (UserNameRequested && !kuserok(&adat, UserNameRequested)) {
-		strcpy(kname, UserNameRequested);
+		strlcpy(kname, UserNameRequested, l);
 		return(AUTH_VALID);
 	} else
 		return(AUTH_USER);
Index: lib/libtelnet/kerberos5.c
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/kerberos5.c,v
retrieving revision 1.10
diff -u -r1.10 kerberos5.c
--- lib/libtelnet/kerberos5.c	2002/09/20 22:25:49	1.10
+++ lib/libtelnet/kerberos5.c	2003/07/15 05:25:40
@@ -577,14 +577,14 @@
 }
 
 int
-kerberos5_status(Authenticator *ap, char *name, int level)
+kerberos5_status(Authenticator *ap, char *name, size_t l, int level)
 {
 	if (level < AUTH_USER)
 		return (level);
 
 	if (UserNameRequested &&
 	    krb5_kuserok(telnet_context, ticket->client, UserNameRequested)) {
-		strcpy(name, UserNameRequested);
+		strlcpy(name, UserNameRequested, l);
 		return (AUTH_VALID);
 	} else
 		return (AUTH_USER);
Index: lib/libtelnet/krb4encpwd.c
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/krb4encpwd.c,v
retrieving revision 1.3
diff -u -r1.3 krb4encpwd.c
--- lib/libtelnet/krb4encpwd.c	2003/07/15 05:09:35	1.3
+++ lib/libtelnet/krb4encpwd.c	2003/07/15 05:25:40
@@ -341,9 +341,10 @@
 }
 
 	int
-krb4encpwd_status(ap, name, level)
+krb4encpwd_status(ap, name, l, level)
 	Authenticator *ap;
 	char *name;
+	size_t l;
 	int level;
 {
 
@@ -351,7 +352,7 @@
 		return(level);
 
 	if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) {
-		strcpy(name, UserNameRequested);
+		strlcpy(name, UserNameRequested, l);
 		return(AUTH_VALID);
 	} else {
 		return(AUTH_USER);
Index: lib/libtelnet/spx.c
===================================================================
RCS file: /cvsroot/src/lib/libtelnet/spx.c,v
retrieving revision 1.3
diff -u -r1.3 spx.c
--- lib/libtelnet/spx.c	2003/07/15 05:09:35	1.3
+++ lib/libtelnet/spx.c	2003/07/15 05:25:40
@@ -481,9 +481,10 @@
 }
 
 	int
-spx_status(ap, name, level)
+spx_status(ap, name, l, level)
 	Authenticator *ap;
 	char *name;
+	size_t l;
 	int level;
 {
 
@@ -521,7 +522,7 @@
 					&acl_file_buffer);
 
 	if (major_status == GSS_S_COMPLETE) {
-	  strcpy(name, UserNameRequested);
+	  strlcpy(name, UserNameRequested, l);
 	  return(AUTH_VALID);
 	} else {
 	   return(AUTH_USER);
Index: libexec/telnetd/telnetd.c
===================================================================
RCS file: /cvsroot/src/libexec/telnetd/telnetd.c,v
retrieving revision 1.40
diff -u -r1.40 telnetd.c
--- libexec/telnetd/telnetd.c	2003/07/14 16:17:37	1.40
+++ libexec/telnetd/telnetd.c	2003/07/15 05:25:40
@@ -127,7 +127,7 @@
 
 int main __P((int, char *[]));
 void usage __P((void));
-int getterminaltype __P((char *));
+int getterminaltype __P((char *, size_t));
 int getent __P((char *, char *));
 void doit __P((struct sockaddr *));
 void _gettermname __P((void));
@@ -492,8 +492,9 @@
 };
 
 int
-getterminaltype(name)
+getterminaltype(name, l)
     char *name;
+    size_t l;
 {
     int retval = -1;
 
@@ -506,7 +507,7 @@
     while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
 	ttloop();
     if (his_state_is_will(TELOPT_AUTHENTICATION)) {
-	retval = auth_wait(name);
+	retval = auth_wait(name, l);
     }
 #endif
 
@@ -729,7 +730,7 @@
 	 * get terminal type.
 	 */
 	*user_name = 0;
-	level = getterminaltype(user_name);
+	level = getterminaltype(user_name, sizeof(user_name));
 	setenv("TERM", terminaltype ? terminaltype : "network", 1);
 
 	/*