diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-25 02:09:41 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-11-23 05:31:30 +0100 |
commit | 5b939a6d290651bcd836083d2a3e6fa6ff7bc636 (patch) | |
tree | f8462334f5bce3231c2a1ad7340cea24f28d5bca | |
parent | d326be2850ea2bd78fe2c22d6c45c3b861d82937 (diff) | |
download | busybox-w32-5b939a6d290651bcd836083d2a3e6fa6ff7bc636.tar.gz busybox-w32-5b939a6d290651bcd836083d2a3e6fa6ff7bc636.tar.bz2 busybox-w32-5b939a6d290651bcd836083d2a3e6fa6ff7bc636.zip |
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.c | 9 |
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: { | |||
12635 | do { | 12635 | do { |
12636 | STPUTC(c, out); | 12636 | STPUTC(c, out); |
12637 | c = pgetc_eatbnl(); | 12637 | c = pgetc_eatbnl(); |
12638 | } while (!subtype && isdigit(c)); | 12638 | } while ((subtype == 0 || subtype == VSLENGTH) && isdigit(c)); |
12639 | } else if (c != '}') { | 12639 | } else if (c != '}') { |
12640 | /* $[{[#]]<specialchar>[}] */ | 12640 | /* $[{[#]]<specialchar>[}] */ |
12641 | int cc = c; | 12641 | int cc = c; |
@@ -12665,11 +12665,6 @@ parsesub: { | |||
12665 | } else | 12665 | } else |
12666 | goto badsub; | 12666 | goto badsub; |
12667 | 12667 | ||
12668 | if (c != '}' && subtype == VSLENGTH) { | ||
12669 | /* ${#VAR didn't end with } */ | ||
12670 | goto badsub; | ||
12671 | } | ||
12672 | |||
12673 | if (subtype == 0) { | 12668 | if (subtype == 0) { |
12674 | static const char types[] ALIGN1 = "}-+?="; | 12669 | static const char types[] ALIGN1 = "}-+?="; |
12675 | /* ${VAR...} but not $VAR or ${#VAR} */ | 12670 | /* ${VAR...} but not $VAR or ${#VAR} */ |
@@ -12726,6 +12721,8 @@ parsesub: { | |||
12726 | #endif | 12721 | #endif |
12727 | } | 12722 | } |
12728 | } else { | 12723 | } else { |
12724 | if (subtype == VSLENGTH && c != '}') | ||
12725 | subtype = 0; | ||
12729 | badsub: | 12726 | badsub: |
12730 | pungetc(); | 12727 | pungetc(); |
12731 | } | 12728 | } |