summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-25 02:09:41 +0200
committerDenys Vlasenko2021-06-25 02:09:41 +0200
commit53a7a9cd8c15d64fcc2278cf8981ba526dfbe0d2 (patch)
tree82b929b38153d536da60dde5ca7e6938cf26a0ff /shell
parentad57e4e4b23926002ce72979729b017520bef1d0 (diff)
downloadbusybox-53a7a9cd8c15d64fcc2278cf8981ba526dfbe0d2.zip
busybox-53a7a9cd8c15d64fcc2278cf8981ba526dfbe0d2.tar.gz
ash: parser: Fix VSLENGTH parsing with trailing garbage
Let's adopt Herbert Xu's patch, not waiting for it to reach dash git: hush already has a similar fix. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index bee8192..2eac6e1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12751,7 +12751,7 @@ parsesub: {
do {
STPUTC(c, out);
c = pgetc_eatbnl();
- } while (!subtype && isdigit(c));
+ } while ((subtype == 0 || subtype == VSLENGTH) && isdigit(c));
} else if (c != '}') {
/* $[{[#]]<specialchar>[}] */
int cc = c;
@@ -12781,11 +12781,6 @@ parsesub: {
} else
goto badsub;
- if (c != '}' && subtype == VSLENGTH) {
- /* ${#VAR didn't end with } */
- goto badsub;
- }
-
if (subtype == 0) {
static const char types[] ALIGN1 = "}-+?=";
/* ${VAR...} but not $VAR or ${#VAR} */
@@ -12842,6 +12837,8 @@ parsesub: {
#endif
}
} else {
+ if (subtype == VSLENGTH && c != '}')
+ subtype = 0;
badsub:
pungetc();
}