aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-04-12 18:02:13 -0500
committerRob Landley <rob@landley.net>2020-04-12 18:02:13 -0500
commitc33c60d84cad4f9a2880203c391403b16c72af29 (patch)
tree7d5f1fd91b55fddb2b434ca9dd381cbb5dd33d1b
parent49f93e0c84cec0bda11409d66983906dd35999ce (diff)
downloadtoybox-c33c60d84cad4f9a2880203c391403b16c72af29.tar.gz
Fix sh -c 'CONSOLE="$(</sys"' segfault (don't advance twice after quote).
-rw-r--r--toys/pending/sh.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 72c30f82..1da67085 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -563,7 +563,7 @@ static char *parse_word(char *start, int early)
// Things the same unquoted or in most non-single-quote contexts
// start new quote context?
- if (strchr("\"'`", *end)) toybuf[quote++] = *end++;
+ if (strchr("\"'`", *end)) toybuf[quote++] = *end;
// backslash escapes
else if (*end == '\\') {
@@ -2461,7 +2461,7 @@ void sh_main(void)
// if (!FLAG(noprofile)) { }
-if (BUGBUG) { int fd = open("/dev/tty", O_RDWR); dup2(fd, 255); close(fd); }
+if (BUGBUG) { int fd = open("/dev/tty", O_RDWR); if (fd == -1) fd = open("/dev/console", O_RDWR); dup2(fd, 255); close(fd); }
// Is this an interactive shell?
if (ii || (!FLAG(c)&&(FLAG(s)||!toys.optc) && isatty(0))) {
ii = 1;