From 18b719de8043103c15fcb82bd5396092812bd00b Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 2 Dec 1988 15:39:59 +0000 Subject: [PATCH] killbss routine smarter now; does not overwrite all BSS; did not work as it should, because systemcall interface also uses the fact that BSS = 0 --- lang/m2/libm2/XXTermcap.c | 35 ++++++++++++++++++++++------------- lang/m2/libm2/halt.c | 2 +- lang/m2/libm2/init.c | 26 +++++++++++++++++++++++--- lang/m2/libm2/stackprio.c | 2 +- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/lang/m2/libm2/XXTermcap.c b/lang/m2/libm2/XXTermcap.c index be7e4bdf0..46ff28c41 100644 --- a/lang/m2/libm2/XXTermcap.c +++ b/lang/m2/libm2/XXTermcap.c @@ -19,12 +19,12 @@ #define ISSPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') #define ISDIGIT(x) ((x) >= '0' && (x) <= '9') -short ospeed; /* output speed */ -char PC; /* padding character */ -char *BC; /* back cursor movement */ -char *UP; /* up cursor movement */ +short ospeed = 0; /* output speed */ +char PC = 0; /* padding character */ +char *BC = 0; /* back cursor movement */ +char *UP = 0; /* up cursor movement */ -static char *capab; /* the capability itself */ +static char *capab = 0; /* the capability itself */ static int check_for_tc(); static int match_name(); @@ -181,8 +181,10 @@ char *name; else file = "/etc/termcap"; } else file = "/etc/termcap"; - if ((fp = open(file, 0)) < 0) + if ((fp = open(file, 0)) < 0) { + capab = 0; return(-1); + } while (fgets(buf, 1024, fp) != NULL) { if (buf[0] == '#') continue; while (*(cp = &buf[strlen(buf) - 2]) == '\\') @@ -191,9 +193,14 @@ char *name; if (match_name(buf, name)) { strcpy(bp, buf); close(fp); - return(check_for_tc()); + if(check_for_tc() == 0) { + capab = 0; + return 0; + } + return 1; } } + capab = 0; close(fp); return(0); } @@ -236,7 +243,9 @@ check_for_tc() return(0); /* no : in termcap entry */ if (p[1] != 't' || p[2] != 'c') return(1); - if (count > 16) return(0); /* recursion in tc= definitions */ + if (count > 16) { + return(0); /* recursion in tc= definitions */ + } count++; strcpy(terminalname, &p[4]); q = terminalname; @@ -264,9 +273,9 @@ char *id; char *cp; int ret; - if ((cp = capab) == NULL || id == NULL) + if ((cp = capab) == NULL || id == NULL || *cp == 0) return(-1); - while (*++cp != ':') + while (*++cp && *cp != ':') ; while (*cp) { cp++; @@ -298,9 +307,9 @@ char *id; { char *cp; - if ((cp = capab) == NULL || id == NULL) + if ((cp = capab) == NULL || id == NULL || *cp == 0) return(-1); - while (*++cp != ':') + while (*++cp && *cp != ':') ; while (*cp) { cp++; @@ -328,7 +337,7 @@ char **area; char *ret; int i; - if ((cp = capab) == NULL || id == NULL) + if ((cp = capab) == NULL || id == NULL || *cp == 0) return(NULL); while (*++cp != ':') ; diff --git a/lang/m2/libm2/halt.c b/lang/m2/libm2/halt.c index e32e8900f..01eeef3f2 100644 --- a/lang/m2/libm2/halt.c +++ b/lang/m2/libm2/halt.c @@ -10,7 +10,7 @@ */ #define MAXPROCS 16 -static int callindex; +static int callindex = 0; static int (*proclist[MAXPROCS])(); _cleanup() diff --git a/lang/m2/libm2/init.c b/lang/m2/libm2/init.c index 37b3231b5..be9069027 100644 --- a/lang/m2/libm2/init.c +++ b/lang/m2/libm2/init.c @@ -31,10 +31,30 @@ init() sigtrp(M2_UNIXSIG, SIGALRM); sigtrp(M2_UNIXSIG, SIGTERM); } +#if em22 || em24 || em44 +killbss() +{ +} +#else + +static int blablabla; /* We cannot use end, because then also + bss allocated for the systemcall lib + would be overwritten. Lets hope that + this helps ... + */ + +killbss() +{ + extern char *edata; + register char *p = (char *) &edata; + + while (p < (char *) &blablabla) *p++ = 0x66; +} +#endif extern int catch(); int (*handler)() = catch; -char **argv, **environ; -int argc, StackSize; -char *CurrentProcess, MainProcess, StackBase, MainLB; +char **argv = 0, **environ = 0; +int argc = 0, StackSize = 0; +char *CurrentProcess = 0, MainProcess = 0, StackBase = 0, MainLB = 0; diff --git a/lang/m2/libm2/stackprio.c b/lang/m2/libm2/stackprio.c index a32044062..ecd3fee2a 100644 --- a/lang/m2/libm2/stackprio.c +++ b/lang/m2/libm2/stackprio.c @@ -9,7 +9,7 @@ Version: $Header$ */ -static unsigned prio; +static unsigned prio = 0; stackprio(n) unsigned n; -- 2.34.1