summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-05-30 14:20:32 +0000
committerjilles <jilles@FreeBSD.org>2010-05-30 14:20:32 +0000
commite65f4ccf953ffadefbbd679eab31c34ae3a31a92 (patch)
tree9e2de3ee284decbd9e2f657e05341f7a07d597fa
parent930ce3922652c50fc8b621b14b6238b325d7f16f (diff)
downloadFreeBSD-src-e65f4ccf953ffadefbbd679eab31c34ae3a31a92.zip
FreeBSD-src-e65f4ccf953ffadefbbd679eab31c34ae3a31a92.tar.gz
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.
-rw-r--r--bin/sh/parser.c1
-rw-r--r--tools/regression/bin/sh/parser/heredoc6.05
2 files changed, 6 insertions, 0 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index c9305b3..05015d2 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -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;
diff --git a/tools/regression/bin/sh/parser/heredoc6.0 b/tools/regression/bin/sh/parser/heredoc6.0
new file mode 100644
index 0000000..3a634de
--- /dev/null
+++ b/tools/regression/bin/sh/parser/heredoc6.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+r=
+! command eval ": <<EOF; )" 2>/dev/null; command eval : hi \${r:=0}
+exit ${r:-3}
OpenPOWER on IntegriCloud