mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
ash: fix a SEGV case in an invalid heredoc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
a14fa79592
commit
7e66102f76
15
shell/ash.c
15
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: "<<EOF; then <W".
|
||||
* It used to segfault w/o this check:
|
||||
*/
|
||||
if (heredoclist) {
|
||||
raise_error_unexpected_syntax(-1);
|
||||
}
|
||||
return n1;
|
||||
}
|
||||
break;
|
||||
case TEOF:
|
||||
if (heredoclist)
|
||||
@ -12046,7 +12053,7 @@ readtoken(void)
|
||||
}
|
||||
|
||||
static char
|
||||
peektoken(void)
|
||||
nexttoken_ends_list(void)
|
||||
{
|
||||
int t;
|
||||
|
||||
|
1
shell/ash_test/ash-heredoc/heredoc1.right
Normal file
1
shell/ash_test/ash-heredoc/heredoc1.right
Normal file
@ -0,0 +1 @@
|
||||
heredoc1.tests: line 3: syntax error: unexpected "then"
|
3
shell/ash_test/ash-heredoc/heredoc1.tests
Executable file
3
shell/ash_test/ash-heredoc/heredoc1.tests
Executable file
@ -0,0 +1,3 @@
|
||||
# We used to SEGV on this:
|
||||
|
||||
<<EOF; then <W
|
Loading…
Reference in New Issue
Block a user