diff options
-rw-r--r-- | shell/ash.c | 15 | ||||
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc1.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc1.tests | 3 |
3 files changed, 15 insertions, 4 deletions
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); | |||
10556 | static union node *pipeline(void); | 10556 | static union node *pipeline(void); |
10557 | static union node *parse_command(void); | 10557 | static union node *parse_command(void); |
10558 | static void parseheredoc(void); | 10558 | static void parseheredoc(void); |
10559 | static char peektoken(void); | 10559 | static char nexttoken_ends_list(void); |
10560 | static int readtoken(void); | 10560 | static int readtoken(void); |
10561 | 10561 | ||
10562 | static union node * | 10562 | static union node * |
@@ -10566,7 +10566,7 @@ list(int nlflag) | |||
10566 | int tok; | 10566 | int tok; |
10567 | 10567 | ||
10568 | checkkwd = CHKNL | CHKKWD | CHKALIAS; | 10568 | checkkwd = CHKNL | CHKKWD | CHKALIAS; |
10569 | if (nlflag == 2 && peektoken()) | 10569 | if (nlflag == 2 && nexttoken_ends_list()) |
10570 | return NULL; | 10570 | return NULL; |
10571 | n1 = NULL; | 10571 | n1 = NULL; |
10572 | for (;;) { | 10572 | for (;;) { |
@@ -10608,8 +10608,15 @@ list(int nlflag) | |||
10608 | tokpushback = 1; | 10608 | tokpushback = 1; |
10609 | } | 10609 | } |
10610 | checkkwd = CHKNL | CHKKWD | CHKALIAS; | 10610 | checkkwd = CHKNL | CHKKWD | CHKALIAS; |
10611 | if (peektoken()) | 10611 | if (nexttoken_ends_list()) { |
10612 | /* Testcase: "<<EOF; then <W". | ||
10613 | * It used to segfault w/o this check: | ||
10614 | */ | ||
10615 | if (heredoclist) { | ||
10616 | raise_error_unexpected_syntax(-1); | ||
10617 | } | ||
10612 | return n1; | 10618 | return n1; |
10619 | } | ||
10613 | break; | 10620 | break; |
10614 | case TEOF: | 10621 | case TEOF: |
10615 | if (heredoclist) | 10622 | if (heredoclist) |
@@ -12046,7 +12053,7 @@ readtoken(void) | |||
12046 | } | 12053 | } |
12047 | 12054 | ||
12048 | static char | 12055 | static char |
12049 | peektoken(void) | 12056 | nexttoken_ends_list(void) |
12050 | { | 12057 | { |
12051 | int t; | 12058 | int t; |
12052 | 12059 | ||
diff --git a/shell/ash_test/ash-heredoc/heredoc1.right b/shell/ash_test/ash-heredoc/heredoc1.right new file mode 100644 index 000000000..895f5ee80 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc1.right | |||
@@ -0,0 +1 @@ | |||
heredoc1.tests: line 3: syntax error: unexpected "then" | |||
diff --git a/shell/ash_test/ash-heredoc/heredoc1.tests b/shell/ash_test/ash-heredoc/heredoc1.tests new file mode 100755 index 000000000..a912a67c7 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc1.tests | |||
@@ -0,0 +1,3 @@ | |||
1 | # We used to SEGV on this: | ||
2 | |||
3 | <<EOF; then <W | ||