← Commit list

a2e32b324

Denys Vlasenko
Denys Vlasenko
2017-10-12
SUCCESS Duration: 144s

Subject

ash: survive failures in $PS1 expansion. Closes 10371

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+18 -1
@@ -12656,7 +12656,24 @@ expandstr(const char *ps, int syntax_type)
saveprompt = doprompt;
doprompt = 0;
- readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
+
+ /* readtoken1() might die horribly.
+ * Try a prompt with syntacticallyt wrong command:
+ * PS1='$(date "+%H:%M:%S) > '
+ */
+ {
+ volatile int saveint;
+ struct jmploc *volatile savehandler = exception_handler;
+ struct jmploc jmploc;
+ SAVE_INT(saveint);
+ if (setjmp(jmploc.loc) == 0) {
+ exception_handler = &jmploc;
+ readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
+ }
+ exception_handler = savehandler;
+ RESTORE_INT(saveint);
+ }
+
doprompt = saveprompt;
popfile();