ash: expand: Fix skipping of command substitution when trimming in evalvar
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 17:42:50 +0000 (18:42 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 18:22:32 +0000 (19:22 +0100)
Upstream commit:

    Date: Mon, 28 May 2018 17:09:48 +0800
    expand: Fix skipping of command substitution when trimming in evalvar

    When we are trimming an unset variable in evalvar, any embedded
    command substitution that should have been skipped are not.  This
    can cause them to be evaluated later should there be other command
    substitutions in the same input word.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index 3958db123b6c5e8eece2aab4fe326895d25b74d8..97c7f4ef532700081d35b314c5b8e317fa4a4203 100644 (file)
@@ -7506,6 +7506,8 @@ evalvar(char *p, int flag)
                goto record;
        }
 
+       varlen = 0;
+
  end:
        if (subtype != VSNORMAL) {      /* skip to end of alternative */
                int nesting = 1;