summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-04-03 00:40:25 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-04-19 18:19:29 +0800
commit6348e861b20d0b90275970af7357ac35ef956f16 (patch)
tree4f0d2e94ecf3ceecb14eba8a601fd4ffa8e00114 /src
parentman: correct typos, iff -> if (diff)
downloaddash-6348e861b20d0b90275970af7357ac35ef956f16.tar.gz
dash-6348e861b20d0b90275970af7357ac35ef956f16.zip
parser: Fix parsing of ${}
dash -c 'echo ${}' should print "Bad subtitution" but instead
fails with "Syntax error: Missing '}'".  This is caused by us
reading an extra character beyond the right brace.  This patch
fixes it so that this construct only fails during expansion rather
than during parsing.

Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src')
-rw-r--r--src/parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 6a8a4a4..efa8060 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1262,7 +1262,7 @@ varname:
 				STPUTC(c, out);
 				c = pgetc_eatbnl();
 			} while (is_digit(c));
-		} else {
+		} else if (c != '}') {
 			int cc = c;
 
 			c = pgetc_eatbnl();
@@ -1290,7 +1290,8 @@ varname:
 			}
 
 			USTPUTC(cc, out);
-		}
+		} else
+			goto badsub;
 
 		if (subtype == 0) {
 			int cc = c;
ighlight'> 2021-08-24Import LibreSSL 3.3.4June McEnroe 2021-05-25Bump version to 3.3.3p1 3.3.3p1June McEnroe 2021-05-25build: Add scripts to EXTRA_DISTJune McEnroe 2021-05-25import: Add missing scripts/wrap-compiler-for-flag-checkJune McEnroe 2021-05-08Import LibreSSL 3.3.3June McEnroe 2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe 2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe 2021-04-18Import LibreSSL 3.3.2June McEnroe 2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe 2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe Some compat sources (getentropy_linux.c for example) require OpenSSL. Reported by Robert Scheck. 2020-12-15Import LibreSSL 3.3.1June McEnroe 2020-11-24Import LibreSSL 3.3.0June McEnroe 2020-10-22Import LibreSSL 3.2.2June McEnroe 2020-09-29Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe