[git commit] hush: fix a case where EXIT trap may modify its code mid-flight

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 19 15:58:44 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=46f839c3f7476cb9016c4787729f64a2c24509d1
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
hush_exit                                             93      99      +6

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/hush.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/hush.c b/shell/hush.c
index 85526a9..7b83c73 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1936,7 +1936,7 @@ static void hush_exit(int exitcode)
 	if (G.exiting <= 0 && G_traps && G_traps[0] && G_traps[0][0]) {
 		char *argv[3];
 		/* argv[0] is unused */
-		argv[1] = G_traps[0];
+		argv[1] = xstrdup(G_traps[0]); /* copy, since EXIT trap handler may modify G_traps[0] */
 		argv[2] = NULL;
 		G.exiting = 1; /* prevent EXIT trap recursion */
 		/* Note: G_traps[0] is not cleared!


More information about the busybox-cvs mailing list