diff options
author | jilles <jilles@FreeBSD.org> | 2010-07-25 22:25:52 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-07-25 22:25:52 +0000 |
commit | f8f703f788bf2b6449cbf8ba919cf78165514f0b (patch) | |
tree | 6c8676b01d33f6ffd8f9c8f3ba98c0f556da18cf /bin | |
parent | 0e1b75189b6d3ce284fe41e55aeff9c5357f6c2a (diff) | |
download | FreeBSD-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.c | 3 |
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++; } |