瀏覽代碼

fix wordexp not to read past end of string ending with lone backslash

Rich Felker 6 年之前
父節點
當前提交
7c84547900
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/misc/wordexp.c

+ 1 - 1
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;