explicitly block SIGEXIT and SIGERR in case some idiot defines it

This commit is contained in:
tg
2016-03-01 18:29:48 +00:00
parent 7c93759f66
commit 25a564460e

View File

@@ -27,7 +27,7 @@
#include <sys/file.h> #include <sys/file.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.154 2016/02/24 01:45:59 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.155 2016/03/01 18:29:48 tg Exp $");
Trap sigtraps[ksh_NSIG + 1]; Trap sigtraps[ksh_NSIG + 1];
static struct sigaction Sigact_ign; static struct sigaction Sigact_ign;
@@ -1033,7 +1033,7 @@ inittraps(void)
#endif #endif
if ((cs == NULL) || if ((cs == NULL) ||
(cs[0] == '\0')) (cs[0] == '\0'))
sigtraps[i].name = shf_smprintf("%d", i); sigtraps[i].name = null;
else { else {
char *s; char *s;
@@ -1049,7 +1049,18 @@ inittraps(void)
sigtraps[i].name = s; sigtraps[i].name = s;
while ((*s = ksh_toupper(*s))) while ((*s = ksh_toupper(*s)))
++s; ++s;
/* check for reserved names */
if (!strcmp(sigtraps[i].name, "EXIT") ||
!strcmp(sigtraps[i].name, "ERR")) {
#ifndef MKSH_SMALL
internal_warningf("ignoring invalid signal name %s",
sigtraps[i].name);
#endif
sigtraps[i].name = null;
}
} }
if (sigtraps[i].name == null)
sigtraps[i].name = shf_smprintf("%d", i);
#if HAVE_SYS_SIGLIST #if HAVE_SYS_SIGLIST
sigtraps[i].mess = sys_siglist[i]; sigtraps[i].mess = sys_siglist[i];
#elif HAVE_STRSIGNAL #elif HAVE_STRSIGNAL