Skip to content

Commit

Permalink
busybox: fix ash segfaults after interrupting applet
Browse files Browse the repository at this point in the history
Backported fix from Busybox v1.36.

DONE: RTOS-773
  • Loading branch information
jmaksymowicz committed Feb 9, 2024
1 parent 7a859f9 commit 46f7c3d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions busybox/20-fix-ash-nofork-interrupted.patch
Original file line number Diff line number Diff line change
@@ -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 <applet>_main() */
+ /*
+ * Run <applet>_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

0 comments on commit 46f7c3d

Please sign in to comment.