Author: jilles Date: Sun Sep 13 13:31:51 2015 New Revision: 287749 URL: https://svnweb.freebsd.org/changeset/base/287749
Log: MFC r287081: 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. Added: stable/10/bin/sh/tests/errors/bad-parm-exp7.0 - copied unchanged from r287081, head/bin/sh/tests/errors/bad-parm-exp7.0 stable/10/bin/sh/tests/errors/bad-parm-exp8.0 - copied unchanged from r287081, head/bin/sh/tests/errors/bad-parm-exp8.0 Modified: stable/10/bin/sh/parser.c stable/10/bin/sh/tests/errors/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/sh/parser.c ============================================================================== --- stable/10/bin/sh/parser.c Sun Sep 13 13:00:20 2015 (r287748) +++ stable/10/bin/sh/parser.c Sun Sep 13 13:31:51 2015 (r287749) @@ -1671,7 +1671,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) { @@ -1687,7 +1687,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: stable/10/bin/sh/tests/errors/Makefile ============================================================================== --- stable/10/bin/sh/tests/errors/Makefile Sun Sep 13 13:00:20 2015 (r287748) +++ stable/10/bin/sh/tests/errors/Makefile Sun Sep 13 13:31:51 2015 (r287749) @@ -17,6 +17,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 Copied: stable/10/bin/sh/tests/errors/bad-parm-exp7.0 (from r287081, head/bin/sh/tests/errors/bad-parm-exp7.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/bin/sh/tests/errors/bad-parm-exp7.0 Sun Sep 13 13:31:51 2015 (r287749, copy of r287081, head/bin/sh/tests/errors/bad-parm-exp7.0) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +v=1 +eval ": $(printf '${v-${\372}}')" Copied: stable/10/bin/sh/tests/errors/bad-parm-exp8.0 (from r287081, head/bin/sh/tests/errors/bad-parm-exp8.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/bin/sh/tests/errors/bad-parm-exp8.0 Sun Sep 13 13:31:51 2015 (r287749, copy of r287081, head/bin/sh/tests/errors/bad-parm-exp8.0) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +v=1 +eval ": $(printf '${v-${w\372}}')" _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"