Author: jilles
Date: Sun May 30 14:20:32 2010
New Revision: 208656
URL: http://svn.freebsd.org/changeset/base/208656

Log:
  sh: Fix a crash if a heredoc was not properly ended and parsing continued.
  
  Example (in interactive mode):
    cat <<EOF && )
  The next command typed caused sh to segfault, because the state for the here
  document was not reset.
  
  Like parser_temp, this uses the fact that the parser is not re-entered.

Added:
  head/tools/regression/bin/sh/parser/heredoc6.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==============================================================================
--- head/bin/sh/parser.c        Sun May 30 14:11:27 2010        (r208655)
+++ head/bin/sh/parser.c        Sun May 30 14:20:32 2010        (r208656)
@@ -203,6 +203,7 @@ parsecmd(int interact)
         * which could happen if we add command substitution on PS1/PS2.
         */
        parser_temp_free_all();
+       heredoclist = NULL;
 
        tokpushback = 0;
        doprompt = interact;

Added: head/tools/regression/bin/sh/parser/heredoc6.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/heredoc6.0      Sun May 30 14:20:32 
2010        (r208656)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+r=
+! command eval ": <<EOF; )" 2>/dev/null; command eval : hi \${r:=0}
+exit ${r:-3}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to