+Tue Jan 27 18:27:16 1998 Dan Winship <danw@mit.edu>
+
+ * telnetd.c (getterminaltype): Null-terminate strings and avoid a
+ buffer overrun.
+
+ * ext.h: make terminaltype a char[] instead of a char * for
+ telnetd.c change
+
+ * state.c (suboption): redo handling of terminaltype
+
Fri Jan 23 22:13:02 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
* telnetd.c (telnet, get_default_IM): Instead of using a hardcoded
* state.c (envvarok): Prohibit the passing of TERMCAP, TERMPATH,
TERMINFO, and HOME, since they can be used to exploit a
- security in tgetent.
+ security hole in tgetent.
Wed Apr 9 23:46:40 1997 Tom Yu <tlyu@mit.edu>
extern int auth_negotiated; /* Have we finished all authentication negotiation we plan to finish?*/
extern slcfun slctab[NSLC + 1]; /* slc mapping table */
-extern char *terminaltype;
+extern char terminaltype[41];
/*
* I/O data buffers, pointers, and counters.
} /* end of case TELOPT_TSPEED */
case TELOPT_TTYPE: { /* Yaaaay! */
- static char terminalname[41];
+ char *tt;
if (his_state_is_wont(TELOPT_TTYPE)) /* Ignore if option disabled */
break;
return; /* ??? XXX but, this is the most robust */
}
- terminaltype = terminalname;
+ tt = terminaltype;
- while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
- !SB_EOF()) {
+ while ((tt < (terminaltype + sizeof(terminaltype) - 1)) && !SB_EOF()) {
register int c;
c = SB_GET();
if (isupper(c)) {
c = tolower(c);
}
- *terminaltype++ = c; /* accumulate name */
+ *tt++ = c; /* accumulate name */
}
- *terminaltype = 0;
- terminaltype = terminalname;
+ *tt = 0;
break;
} /* end of case TELOPT_TTYPE */
SCPYN(request.gen_id, gen_id);
SCPYN(request.tty_id, &line[8]);
SCPYN(request.host, host);
- SCPYN(request.term_type, terminaltype ? terminaltype : "network");
+ SCPYN(request.term_type, *terminaltype ? terminaltype : "network");
#if !defined(UNICOS5)
request.signal = SIGCLD;
request.pid = getpid();
* we have to just go with what we (might) have already gotten.
*/
if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
- (void) strncpy(first, terminaltype, sizeof(first));
+ (void) strncpy(first, terminaltype, sizeof(first) - 1);
+ first[sizeof(first) - 1] = '\0';
for(;;) {
/*
* Save the unknown name, and request the next name.
*/
- (void) strncpy(last, terminaltype, sizeof(last));
+ (void) strncpy(last, terminaltype, sizeof(last) - 1);
+ last[sizeof(last) - 1] = '\0';
_gettermname();
if (terminaltypeok(terminaltype))
break;
* RFC1091 compliant telnets will cycle back to
* the start of the list.
*/
- _gettermname();
- if (strncmp(first, terminaltype, sizeof(first)) != 0)
- (void) strncpy(terminaltype, first, sizeof(first));
+ _gettermname();
+ if (strncmp(first, terminaltype, sizeof(first)) != 0) {
+ (void) strncpy(terminaltype, first,
+ sizeof(terminaltype) - 1);
+ terminaltype[sizeof(terminaltype) - 1] = '\0';
+ }
break;
}
}
{
char buf[1024];
- if (terminaltype == NULL)
+ if (!*s)
return(1);
/*