summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-01-30 04:29:03 +0100
committerDenys Vlasenko2018-01-30 04:29:03 +0100
commit749575d3c52c32f57f46f2cbb2942a2204d333ee (patch)
tree8c6269fbc476bbd01b2c6295f86870319b0df9b1
parent6f9442ff30f2fa7b66395935b0f59b01ecc89f0e (diff)
downloadbusybox-749575d3c52c32f57f46f2cbb2942a2204d333ee.zip
busybox-749575d3c52c32f57f46f2cbb2942a2204d333ee.tar.gz
hush: protect against self-modifying trap code
function old new delta check_and_run_traps 211 236 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index ddf3773..585c51b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2004,10 +2004,12 @@ static int check_and_run_traps(void)
smalluint save_rcode;
char *argv[3];
/* argv[0] is unused */
- argv[1] = G_traps[sig];
+ argv[1] = xstrdup(G_traps[sig]);
+ /* why strdup? trap can modify itself: trap 'trap "echo oops" INT' INT */
argv[2] = NULL;
save_rcode = G.last_exitcode;
builtin_eval(argv);
+ free(argv[1]);
//FIXME: shouldn't it be set to 128 + sig instead?
G.last_exitcode = save_rcode;
last_sig = sig;