From owner-svn-src-all@freebsd.org Sun Aug 23 20:44:55 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 848809C0345; Sun, 23 Aug 2015 20:44:55 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A395114B; Sun, 23 Aug 2015 20:44:55 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NKit43006914; Sun, 23 Aug 2015 20:44:55 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NKisCs006909; Sun, 23 Aug 2015 20:44:54 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201508232044.t7NKisCs006909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 23 Aug 2015 20:44:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287081 - in head/bin/sh: . tests/errors X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 20:44:55 -0000 Author: jilles Date: Sun Aug 23 20:44:53 2015 New Revision: 287081 URL: https://svnweb.freebsd.org/changeset/base/287081 Log: sh: Don't create bad parse result when postponing a bad substitution error. An invalid substitution like ${var@} does not cause a parse error but is stored in the intermediate representation, to be written as part of the error message. If there is a CTL* byte in the stored part, this confuses some code such as the code to skip an unused alternative such as in ${var-alternative}. To keep things simple, do not store CTL* bytes. Found with afl-fuzz. MFC after: 1 week Added: head/bin/sh/tests/errors/bad-parm-exp7.0 (contents, props changed) head/bin/sh/tests/errors/bad-parm-exp8.0 (contents, props changed) Modified: head/bin/sh/parser.c head/bin/sh/tests/errors/Makefile Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sun Aug 23 20:39:19 2015 (r287080) +++ head/bin/sh/parser.c Sun Aug 23 20:44:53 2015 (r287081) @@ -1662,7 +1662,7 @@ varname: pungetc(); else if (c == '\n' || c == PEOF) synerror("Unexpected end of line in substitution"); - else + else if (BASESYNTAX[c] != CCTL) USTPUTC(c, out); } if (subtype == 0) { @@ -1678,7 +1678,8 @@ varname: synerror("Unexpected end of line in substitution"); if (flags == VSNUL) STPUTC(':', out); - STPUTC(c, out); + if (BASESYNTAX[c] != CCTL) + STPUTC(c, out); subtype = VSERROR; } else subtype = p - types + VSNORMAL; Modified: head/bin/sh/tests/errors/Makefile ============================================================================== --- head/bin/sh/tests/errors/Makefile Sun Aug 23 20:39:19 2015 (r287080) +++ head/bin/sh/tests/errors/Makefile Sun Aug 23 20:44:53 2015 (r287081) @@ -19,6 +19,8 @@ FILES+= bad-parm-exp3.2 bad-parm-exp3.2 FILES+= bad-parm-exp4.2 bad-parm-exp4.2.stderr FILES+= bad-parm-exp5.2 bad-parm-exp5.2.stderr FILES+= bad-parm-exp6.2 bad-parm-exp6.2.stderr +FILES+= bad-parm-exp7.0 +FILES+= bad-parm-exp8.0 FILES+= option-error.0 FILES+= redirection-error.0 FILES+= redirection-error2.2 Added: head/bin/sh/tests/errors/bad-parm-exp7.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/errors/bad-parm-exp7.0 Sun Aug 23 20:44:53 2015 (r287081) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +v=1 +eval ": $(printf '${v-${\372}}')" Added: head/bin/sh/tests/errors/bad-parm-exp8.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/errors/bad-parm-exp8.0 Sun Aug 23 20:44:53 2015 (r287081) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +v=1 +eval ": $(printf '${v-${w\372}}')"