aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-10-12 19:20:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-10-12 19:20:13 +0200
commita2e32b324eb7440f0cd4992f54f7a5822c145e91 (patch)
tree7b36bca131ac4f8f2f535f9b8b66dcb0c7860cf7
parent0fd5dbba8f34e006aa0e999002d31e79daf2fdf3 (diff)
downloadbusybox-w32-a2e32b324eb7440f0cd4992f54f7a5822c145e91.tar.gz
busybox-w32-a2e32b324eb7440f0cd4992f54f7a5822c145e91.tar.bz2
busybox-w32-a2e32b324eb7440f0cd4992f54f7a5822c145e91.zip
ash: survive failures in $PS1 expansion. Closes 10371
function old new delta expandstr 120 209 +89 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 39705a350..ef81ea70f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12656,7 +12656,24 @@ expandstr(const char *ps, int syntax_type)
12656 12656
12657 saveprompt = doprompt; 12657 saveprompt = doprompt;
12658 doprompt = 0; 12658 doprompt = 0;
12659 readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0); 12659
12660 /* readtoken1() might die horribly.
12661 * Try a prompt with syntacticallyt wrong command:
12662 * PS1='$(date "+%H:%M:%S) > '
12663 */
12664 {
12665 volatile int saveint;
12666 struct jmploc *volatile savehandler = exception_handler;
12667 struct jmploc jmploc;
12668 SAVE_INT(saveint);
12669 if (setjmp(jmploc.loc) == 0) {
12670 exception_handler = &jmploc;
12671 readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
12672 }
12673 exception_handler = savehandler;
12674 RESTORE_INT(saveint);
12675 }
12676
12660 doprompt = saveprompt; 12677 doprompt = saveprompt;
12661 12678
12662 popfile(); 12679 popfile();