From e5900c5239238466173cb429b7bcab51603bc4ad Mon Sep 17 00:00:00 2001 From: Jacek Maksymowicz Date: Fri, 9 Feb 2024 16:09:14 +0100 Subject: [PATCH] busybox: fix ash segfaults after interrupting applet Backported fix from Busybox v1.36. DONE: RTOS-773 --- busybox/20-fix-ash-nofork-interrupted.patch | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 busybox/20-fix-ash-nofork-interrupted.patch diff --git a/busybox/20-fix-ash-nofork-interrupted.patch b/busybox/20-fix-ash-nofork-interrupted.patch new file mode 100644 index 0000000..44c759b --- /dev/null +++ b/busybox/20-fix-ash-nofork-interrupted.patch @@ -0,0 +1,23 @@ +diff --git a/shell/ash.c b/shell/ash.c +--- a/shell/ash.c ++++ b/shell/ash.c +@@ -9745,9 +9745,18 @@ evalcommand(union node *cmd, int flags) + /* find_command() encodes applet_no as (-2 - applet_no) */ + int applet_no = (- cmdentry.u.index - 2); + if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { ++ INT_OFF; + listsetvar(varlist.list, VEXPORT|VSTACK); +- /* run _main() */ ++ /* ++ * Run _main(). ++ * Signals (^C) can't interrupt here. ++ * Otherwise we can mangle stdio or malloc internal state. ++ * This makes applets which can run for a long time ++ * and/or wait for user input ineligible for NOFORK: ++ * for example, "yes" or "rm" (rm -i waits for input). ++ */ + status = run_nofork_applet(applet_no, argv); ++ INT_ON; + break; + } + #endif