summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-07-25 22:25:52 +0000
committerjilles <jilles@FreeBSD.org>2010-07-25 22:25:52 +0000
commitf8f703f788bf2b6449cbf8ba919cf78165514f0b (patch)
tree6c8676b01d33f6ffd8f9c8f3ba98c0f556da18cf /bin
parent0e1b75189b6d3ce284fe41e55aeff9c5357f6c2a (diff)
downloadFreeBSD-src-f8f703f788bf2b6449cbf8ba919cf78165514f0b.zip
FreeBSD-src-f8f703f788bf2b6449cbf8ba919cf78165514f0b.tar.gz
sh: Fix crash due to uninitialized here-document.
If an ; or & token was followed by an EOF token, pending here-documents were left uninitialized. Execution would crash, either in the main shell process for literal here-documents or in a child process for expanded here-documents. In the latter case the problem is hard to detect apart from the core dumps and log messages. Side effect: slightly different retries on inputs where EOF is not persistent. Note that tools/regression/bin/sh/parser/heredoc6.0 still causes a similar crash in a child process. The text passed to eval is malformed and should be rejected.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/parser.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 9c89d9f..69d3e6f 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -269,6 +269,9 @@ list(int nlflag)
parseheredoc();
if (nlflag)
return n1;
+ } else if (tok == TEOF && nlflag) {
+ parseheredoc();
+ return n1;
} else {
tokpushback++;
}
OpenPOWER on IntegriCloud