Date: Tue, 23 Jul 2013 21:09:26 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253581 - in head: lib/libc/gen tools/regression/lib/libc/gen Message-ID: <201307232109.r6NL9QJ7064052@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Tue Jul 23 21:09:26 2013 New Revision: 253581 URL: http://svnweb.freebsd.org/changeset/base/253581 Log: wordexp(): Fix syntax validation for backslashes in single-quotes. Modified: head/lib/libc/gen/wordexp.c head/tools/regression/lib/libc/gen/test-wordexp.c Modified: head/lib/libc/gen/wordexp.c ============================================================================== --- head/lib/libc/gen/wordexp.c Tue Jul 23 19:34:09 2013 (r253580) +++ head/lib/libc/gen/wordexp.c Tue Jul 23 21:09:26 2013 (r253581) @@ -251,7 +251,8 @@ we_check(const char *words, int flags) while ((c = *words++) != '\0') { switch (c) { case '\\': - quote ^= 1; + if (squote == 0) + quote ^= 1; continue; case '\'': if (quote + dquote == 0) Modified: head/tools/regression/lib/libc/gen/test-wordexp.c ============================================================================== --- head/tools/regression/lib/libc/gen/test-wordexp.c Tue Jul 23 19:34:09 2013 (r253580) +++ head/tools/regression/lib/libc/gen/test-wordexp.c Tue Jul 23 21:09:26 2013 (r253581) @@ -195,6 +195,18 @@ main(int argc, char *argv[]) r = wordexp("test } test", &we, 0); assert(r == WRDE_BADCHAR); + /* WRDE_SYNTAX */ + r = wordexp("'", &we, 0); + assert(r == WRDE_SYNTAX); + r = wordexp("'", &we, WRDE_UNDEF); + assert(r == WRDE_SYNTAX); + r = wordexp("'\\'", &we, 0); + assert(r == 0); + assert(we.we_wordc == 1); + assert(strcmp(we.we_wordv[0], "\\") == 0); + assert(we.we_wordv[1] == NULL); + wordfree(&we); + /* With a SIGCHLD handler that reaps all zombies. */ sa.sa_flags = 0; sigemptyset(&sa.sa_mask);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307232109.r6NL9QJ7064052>