diff --git a/telnetd/ext.h b/telnetd/ext.h index 2243b43..61db4a8 100644 --- a/telnetd/ext.h +++ b/telnetd/ext.h @@ -80,6 +80,9 @@ extern int pty, net; extern char line[32]; extern int SYNCHing; /* we are in TELNET SYNCH mode */ +/* Buffer for miscellaneous uses in various functions */ +extern char buf[BUFSIZ > 1024 ? BUFSIZ : 1024]; + extern void _termstat(void), add_slc(char, char, cc_t), diff --git a/telnetd/state.c b/telnetd/state.c index 998b500..204473a 100644 --- a/telnetd/state.c +++ b/telnetd/state.c @@ -1495,7 +1495,7 @@ doclientstat(void) void send_status(void) { - unsigned char statusbuf[256]; + static unsigned char statusbuf[256]; unsigned char *ncp; unsigned char i; diff --git a/telnetd/sys_term.c b/telnetd/sys_term.c index 86e2c5b..05116d1 100644 --- a/telnetd/sys_term.c +++ b/telnetd/sys_term.c @@ -1288,5 +1288,5 @@ cleanup(int sig __unused) { (void) shutdown(net, SHUT_RDWR); - _exit(1); + exit(1); } diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c index de412e6..4f3821a 100644 --- a/telnetd/telnetd.c +++ b/telnetd/telnetd.c @@ -43,6 +43,7 @@ static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; #include "pathnames.h" #ifdef __GNO__ +#include #include "libtelnet/getaddrinfo.h" /* GNO doesn't have struct sockaddr_storage; just use "struct sockaddr" * (which is really struct osockaddr). */ @@ -65,6 +66,10 @@ int auth_level = 0; #endif #include "libtelnet/misc.h" +#ifdef __ORCAC__ +#pragma stacksize 1536 +#endif + char remote_hostname[MAXHOSTNAMELEN]; size_t utmp_len = sizeof(remote_hostname) - 1; int registerd_host_only = 0; @@ -145,16 +150,26 @@ main(int argc, char *argv[]) #endif char *ep; + +#ifdef __GNO__ + if (getenv("TELNETD_STACKCHECK") != NULL) + _reportStack(); + + /* Make sure our environment is isolated from the parent process's */ + if (environPush() == 0) + atexit(environPop); + else + exit(1); + environInit(); +#endif + pfrontp = pbackp = ptyobuf; netip = netibuf; nfrontp = nbackp = netobuf; #ifdef ENCRYPTION nclearto = 0; #endif /* ENCRYPTION */ - -#ifdef __GNO__ - environInit(); -#endif + /* * This initialization causes linemode to default to a configuration @@ -579,7 +594,7 @@ getterminaltype(char *name undef2) ttloop(); } if (his_state_is_will(TELOPT_TTYPE)) { - char first[256], last[256]; + static char first[256], last[256]; while (sequenceIs(ttypesubopt, baseline)) ttloop(); @@ -647,8 +662,6 @@ _gettermname(void) int terminaltypeok(char *s) { - char buf[1024]; - if (terminaltype == NULL) return(1); @@ -768,8 +781,8 @@ telnet(int f, int p, char *host) { int on = 1; #define TABBUFSIZ 512 - char defent[TABBUFSIZ]; - char defstrs[TABBUFSIZ]; + char *defent = buf; + char *defstrs = buf + TABBUFSIZ; #undef TABBUFSIZ char *HE; char *HN; diff --git a/telnetd/utility.c b/telnetd/utility.c index a87e941..111bcfc 100644 --- a/telnetd/utility.c +++ b/telnetd/utility.c @@ -326,8 +326,6 @@ netflush(void) void fatal(int f, const char *msg) { - char buf[BUFSIZ]; - (void) snprintf(buf, sizeof(buf), "telnetd: %s.\r\n", msg); #ifdef ENCRYPTION if (encrypt_output) { @@ -347,7 +345,7 @@ fatal(int f, const char *msg) void fatalperror(int f, const char *msg) { - char buf[BUFSIZ]; + static char buf[BUFSIZ]; (void) snprintf(buf, sizeof(buf), "%s: %s", msg, strerror(errno)); fatal(f, buf); @@ -722,7 +720,7 @@ printsub(char direction, unsigned char *pointer, int length) break; } { - char tbuf[32]; + static char tbuf[32]; sprintf(tbuf, "%s%s%s%s%s", pointer[2]&MODE_EDIT ? "|EDIT" : "", pointer[2]&MODE_TRAPSIG ? "|TRAPSIG" : "", @@ -1057,7 +1055,7 @@ void printdata(const char *tag, char *ptr, int cnt) { int i; - char xbuf[30]; + static char xbuf[30]; while (cnt) { /* flush net output buffer if no room for new data) */