Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-25 03:09:41 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-11-23 07:31:30 +0300
commit5b939a6d290651bcd836083d2a3e6fa6ff7bc636 (patch)
treef8462334f5bce3231c2a1ad7340cea24f28d5bca
parentd326be2850ea2bd78fe2c22d6c45c3b861d82937 (diff)
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> (cherry picked from commit 53a7a9cd8c15d64fcc2278cf8981ba526dfbe0d2)
-rw-r--r--shell/ash.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index a33ab0626..1ca45f9c1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12635,7 +12635,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;
@@ -12665,11 +12665,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} */
@@ -12726,6 +12721,8 @@ parsesub: {
#endif
}
} else {
+ if (subtype == VSLENGTH && c != '}')
+ subtype = 0;
badsub:
pungetc();
}