add some bounds, for a subsequent commit:

• all writers of exstat ensure the value is in [0; 0xFF]
• all readers of exstat AND it with 0xFF (not strictly needed thus)
• trap_exstat is “safe”, i.e. always either -1 or [0; 0xFF]
This commit is contained in:
tg
2012-10-21 21:39:06 +00:00
parent bebb2d2254
commit 31f24a4040
6 changed files with 22 additions and 20 deletions

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.226 2012/10/03 17:24:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.227 2012/10/21 21:39:02 tg Exp $");
#if HAVE_KILLPG
/*
@ -2280,7 +2280,7 @@ c_exitreturn(const char **wp)
exstat = 1;
warningf(true, "%s: %s", arg, "bad number");
} else
exstat = n;
exstat = n & 0xFF;
} else if (trap_exstat != -1)
exstat = trap_exstat;
if (wp[0][0] == 'r') {