From 3c8e540eb7b7cd3d60d55bb195e26537f83eb836 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 8 May 2023 12:27:50 +0200 Subject: hush: fix an interactive abort on error function old new delta parse_and_run_stream 140 155 +15 Signed-off-by: Denys Vlasenko --- shell/hush.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index f8951d084..ac8e44778 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7589,6 +7589,14 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) } /* Force prompt */ inp->p = NULL; + /* Clear "peeked" EOF. Without this, + * $ { cmd } + * > ^D + * hush: syntax error: unterminated { + * exits interactive shell: + */ + if (inp->peek_buf[0] == EOF) + inp->peek_buf[0] = 0; /* This stream isn't empty */ empty = 0; continue; -- cgit v1.2.3-55-g6feb From 3a7f00eadcf400df5f9381b49f3ff5e882af0261 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 9 May 2023 14:02:06 +0200 Subject: hush: add comment about abort on syntax error %{^} Signed-off-by: Denys Vlasenko --- shell/hush.c | 1 + 1 file changed, 1 insertion(+) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index ac8e44778..810dafd35 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1429,6 +1429,7 @@ static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s) { bb_error_msg("syntax error: unterminated %s", s); //? source4.tests fails: in bash, echo ${^} in script does not terminate the script +// (but bash --posix, or if bash is run as "sh", does terminate in script, so maybe uncomment this?) // die_if_script(); } -- cgit v1.2.3-55-g6feb From 3e83699ce23400d75c7ddaa7ebfdec015177caa7 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Thu, 18 May 2023 16:47:49 +0200 Subject: ash: use-after-free in bash pattern substitution Commit daa66ed6 fixed a number of use-after-free bugs in bash pattern substitution, however one "unguarded" STPUTC remained, which is fixed here. function old new delta subevalvar 1564 1576 +12 Signed-off-by: Karsten Sperling Signed-off-by: Denys Vlasenko --- shell/ash.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index d2c5c5d50..51b627fcc 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7370,6 +7370,8 @@ subevalvar(char *start, char *str, int strloc, char *restart_detect = stackblock(); if (quotes && *loc == '\\') { STPUTC(CTLESC, expdest); + if (stackblock() != restart_detect) + goto restart; len++; } STPUTC(*loc, expdest); -- cgit v1.2.3-55-g6feb