From owner-svn-src-head@FreeBSD.ORG Tue Jul 23 21:09:27 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1E797E96; Tue, 23 Jul 2013 21:09:27 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0F19E255A; Tue, 23 Jul 2013 21:09:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6NL9Q7Q064054; Tue, 23 Jul 2013 21:09:26 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6NL9QJ7064052; Tue, 23 Jul 2013 21:09:26 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201307232109.r6NL9QJ7064052@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 23 Jul 2013 21:09:26 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jul 2013 21:09:27 -0000 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);