fix bad character checking in wordexp
authorRich Felker <dalias@aerifal.cx>
Wed, 11 Feb 2015 06:37:01 +0000 (01:37 -0500)
committerRich Felker <dalias@aerifal.cx>
Mon, 30 Mar 2015 05:45:20 +0000 (01:45 -0400)
the character sequence '$((' was incorrectly interpreted as the
opening of arithmetic even within single-quoted contexts, thereby
suppressing the checks for bad characters after the closing quote.

presently bad character checking is only performed when the WRDE_NOCMD
is used; this patch only corrects checking in that case.

(cherry picked from commit 594ffed82f4e6ee7da85e9c5da35e32946ae32c9)

src/misc/wordexp.c

index a5f1b658ce0600c6d4e48d53a692a64faafaa79e..db39b5b8a3e3dee78bf6a54c1af3a1e23013c72b 100644 (file)
@@ -77,6 +77,7 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags)
                if (!(sq|dq|np)) return WRDE_BADCHAR;
                break;
        case '$':
+               if (sq) break;
                if (s[i+1]=='(' && s[i+2]=='(') {
                        i += 2;
                        np += 2;