From 7e66102f762a7d80715f0c7e5925433256b78cee Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 5 Feb 2015 21:00:17 +0100 Subject: ash: fix a SEGV case in an invalid heredoc Signed-off-by: Denys Vlasenko --- shell/ash.c | 15 +++++++++++---- shell/ash_test/ash-heredoc/heredoc1.right | 1 + shell/ash_test/ash-heredoc/heredoc1.tests | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 shell/ash_test/ash-heredoc/heredoc1.right create mode 100755 shell/ash_test/ash-heredoc/heredoc1.tests (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index c5ad96909..0f9f73ec3 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10556,7 +10556,7 @@ static union node *andor(void); static union node *pipeline(void); static union node *parse_command(void); static void parseheredoc(void); -static char peektoken(void); +static char nexttoken_ends_list(void); static int readtoken(void); static union node * @@ -10566,7 +10566,7 @@ list(int nlflag) int tok; checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (nlflag == 2 && peektoken()) + if (nlflag == 2 && nexttoken_ends_list()) return NULL; n1 = NULL; for (;;) { @@ -10608,8 +10608,15 @@ list(int nlflag) tokpushback = 1; } checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (peektoken()) + if (nexttoken_ends_list()) { + /* Testcase: "<