Remove static local variable so its easier to correctly use strlcpy.

This commit is contained in:
lha 2005-06-21 22:29:53 +00:00
parent d1f006118e
commit 3baf9430ad
3 changed files with 13 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext.h,v 1.19 2005/02/06 05:58:20 perry Exp $ */
/* $NetBSD: ext.h,v 1.20 2005/06/21 22:29:53 lha Exp $ */
/*
* Copyright (c) 1989, 1993
@ -60,7 +60,7 @@ extern int auth_level;
#endif
extern slcfun slctab[NSLC + 1]; /* slc mapping table */
extern char *terminaltype;
extern char terminaltype[41];
/*
* I/O data buffers, pointers, and counters.

View File

@ -1,4 +1,4 @@
/* $NetBSD: state.c,v 1.25 2005/02/06 05:58:21 perry Exp $ */
/* $NetBSD: state.c,v 1.26 2005/06/21 22:29:53 lha 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.25 2005/02/06 05:58:21 perry Exp $");
__RCSID("$NetBSD: state.c,v 1.26 2005/06/21 22:29:53 lha Exp $");
#endif
#endif /* not lint */
@ -1140,7 +1140,7 @@ suboption(void)
} /* 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;
@ -1150,9 +1150,9 @@ suboption(void)
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()) {
int c;
@ -1160,10 +1160,9 @@ suboption(void)
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: telnetd.c,v 1.47 2005/06/01 15:57:40 lukem Exp $ */
/* $NetBSD: telnetd.c,v 1.48 2005/06/21 22:29:53 lha Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@ -65,7 +65,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: telnetd.c,v 1.47 2005/06/01 15:57:40 lukem Exp $");
__RCSID("$NetBSD: telnetd.c,v 1.48 2005/06/21 22:29:53 lha Exp $");
#endif
#endif /* not lint */
@ -616,7 +616,7 @@ getterminaltype(char *name, size_t l)
*/
_gettermname();
if (strncmp(first, terminaltype, sizeof(first)) != 0) {
(void) strlcpy(terminaltype, first, sizeof(first));
(void) strlcpy(terminaltype, first, sizeof(terminaltype));
}
break;
}
@ -721,7 +721,7 @@ doit(struct sockaddr *who)
*/
*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