rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 096de180211a0573a80d9380aae99b940ce46a42
parent 7203d4edba0affd77b257610a2fa6e23a37a8da6
Author: tgoodwin <tgoodwin>
Date:   Mon, 20 Jul 1998 10:12:46 +0000

only call WTERMSIG if WIFSIGNALED
also, always check that WTERMSIG is in range

Diffstat:
Mstatus.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/status.c b/status.c @@ -64,7 +64,8 @@ extern void setstatus(pid_t pid, int i) { extern void statprint(pid_t pid, int i) { if (WIFSIGNALED(i)) { - char *msg = (WTERMSIG(i) < NUMOFSIGNALS ? signals[WTERMSIG(i)].msg : ""); + int t = WTERMSIG(i); + char *msg = ((t > 0) && (t < NUMOFSIGNALS) ? signals[WTERMSIG(i)].msg : ""); if (pid != -1) fprint(2, "%ld: ", (long)pid); if (myWIFDUMPED(i)) { @@ -99,11 +100,10 @@ extern List *sgetstatus() { /* return status as a string (used above and for bqstatus) */ extern char *strstatus(int s) { - int t = WTERMSIG(s); - - if (t != 0) { + if (WIFSIGNALED(s)) { + int t = WTERMSIG(s); const char *core = myWIFDUMPED(s) ? "+core" : ""; - if (t < NUMOFSIGNALS && *signals[t].name != '\0') + if ((t > 0) && (t < NUMOFSIGNALS) && *signals[t].name != '\0') return nprint("%s%s", signals[t].name, core); else return nprint("-%d%s", t, core); /* unknown signals are negated */