From 7c8454790080395bf5b27857a766b3468aa5ed98 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 9 Dec 2018 22:20:15 -0500 Subject: [PATCH] fix wordexp not to read past end of string ending with lone backslash --- src/misc/wordexp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c index d123cf75..db83a69f 100644 --- a/src/misc/wordexp.c +++ b/src/misc/wordexp.c @@ -42,7 +42,7 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags) if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) { case '\\': - if (!sq) i++; + if (!sq && !s[++i]) return WRDE_SYNTAX; break; case '\'': if (!dq) sq^=1;