Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/libexec/telnetd Apply patch (requested by lha in ticket...



details:   https://anonhg.NetBSD.org/src/rev/8e58615d743f
branches:  netbsd-2-0
changeset: 564801:8e58615d743f
user:      tron <tron%NetBSD.org@localhost>
date:      Fri Jul 01 15:15:02 2005 +0000

description:
Apply patch (requested by lha in ticket #2041):
Remove static local variable so its easier to correctly use strlcpy.

diffstat:

 libexec/telnetd/ext.h     |   4 ++--
 libexec/telnetd/state.c   |  15 +++++++--------
 libexec/telnetd/telnetd.c |   8 ++++----
 3 files changed, 13 insertions(+), 14 deletions(-)

diffs (106 lines):

diff -r 0733ede9a2c3 -r 8e58615d743f libexec/telnetd/ext.h
--- a/libexec/telnetd/ext.h     Sat Jun 18 04:03:11 2005 +0000
+++ b/libexec/telnetd/ext.h     Fri Jul 01 15:15:02 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext.h,v 1.18 2003/08/07 09:46:51 agc Exp $     */
+/*     $NetBSD: ext.h,v 1.18.2.1 2005/07/01 15:15:02 tron Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -60,7 +60,7 @@
 #endif
 
 extern slcfun  slctab[NSLC + 1];       /* slc mapping table */
-extern char    *terminaltype;
+extern char    terminaltype[41];
 
 /*
  * I/O data buffers, pointers, and counters.
diff -r 0733ede9a2c3 -r 8e58615d743f libexec/telnetd/state.c
--- a/libexec/telnetd/state.c   Sat Jun 18 04:03:11 2005 +0000
+++ b/libexec/telnetd/state.c   Fri Jul 01 15:15:02 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.c,v 1.24 2003/08/07 09:46:51 agc Exp $   */
+/*     $NetBSD: state.c,v 1.24.2.1 2005/07/01 15:15:02 tron Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)state.c    8.5 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: state.c,v 1.24 2003/08/07 09:46:51 agc Exp $");
+__RCSID("$NetBSD: state.c,v 1.24.2.1 2005/07/01 15:15:02 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -1149,7 +1149,7 @@
     }  /* end of case TELOPT_TSPEED */
 
     case TELOPT_TTYPE: {               /* Yaaaay! */
-       static char terminalname[41];
+       char *p;
 
        if (his_state_is_wont(TELOPT_TTYPE))    /* Ignore if option disabled */
                break;
@@ -1159,9 +1159,9 @@
            return;             /* ??? XXX but, this is the most robust */
        }
 
-       terminaltype = terminalname;
+       p = terminaltype;
 
-       while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
+       while ((p < (terminaltype + sizeof terminaltype-1)) &&
                                                                    !SB_EOF()) {
            register int c;
 
@@ -1169,10 +1169,9 @@
            if (isupper(c)) {
                c = tolower(c);
            }
-           *terminaltype++ = c;    /* accumulate name */
+           *p++ = c;    /* accumulate name */
        }
-       *terminaltype = 0;
-       terminaltype = terminalname;
+       *p = 0;
        break;
     }  /* end of case TELOPT_TTYPE */
 
diff -r 0733ede9a2c3 -r 8e58615d743f libexec/telnetd/telnetd.c
--- a/libexec/telnetd/telnetd.c Sat Jun 18 04:03:11 2005 +0000
+++ b/libexec/telnetd/telnetd.c Fri Jul 01 15:15:02 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: telnetd.c,v 1.43 2003/08/07 09:46:52 agc Exp $ */
+/*     $NetBSD: telnetd.c,v 1.43.2.1 2005/07/01 15:15:02 tron Exp $    */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -65,7 +65,7 @@
 #if 0
 static char sccsid[] = "@(#)telnetd.c  8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnetd.c,v 1.43 2003/08/07 09:46:52 agc Exp $");
+__RCSID("$NetBSD: telnetd.c,v 1.43.2.1 2005/07/01 15:15:02 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -620,7 +620,7 @@
                     */
                     _gettermname();
                    if (strncmp(first, terminaltype, sizeof(first)) != 0) {
-                       (void) strlcpy(terminaltype, first, sizeof(first));
+                       (void) strlcpy(terminaltype, first, sizeof(terminaltype));
                    }
                    break;
                }
@@ -727,7 +727,7 @@
         */
        *user_name = 0;
        level = getterminaltype(user_name, sizeof(user_name));
-       setenv("TERM", terminaltype ? terminaltype : "network", 1);
+       setenv("TERM", terminaltype[0] ? terminaltype : "network", 1);
 
        /*
         * Start up the login process on the slave side of the terminal



Home | Main Index | Thread Index | Old Index