aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-02 17:18:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-02 17:18:34 +0200
commitb1cfc453760b3b3b81bb3217f68074a98c96084b (patch)
tree3567c42f4fd94570e3e68fa9b0557fa93f098a7d
parentaa0a12d5495a9cc8612e026ea5787eee4b019095 (diff)
downloadbusybox-w32-b1cfc453760b3b3b81bb3217f68074a98c96084b.tar.gz
busybox-w32-b1cfc453760b3b3b81bb3217f68074a98c96084b.tar.bz2
busybox-w32-b1cfc453760b3b3b81bb3217f68074a98c96084b.zip
hush: fix handling of unterminated subshell: (<eof>. Fixes bug 229.
function old new delta syntax_error_unexpected_ch 31 41 +10 parse_stream 2184 2191 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 5daca960c..255caef01 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -780,12 +780,12 @@ static void syntax_error_unterm_str(unsigned lineno, const char *s)
780 die_if_script(lineno, "syntax error: unterminated %s", s); 780 die_if_script(lineno, "syntax error: unterminated %s", s);
781} 781}
782 782
783static void syntax_error_unexpected_ch(unsigned lineno, char ch) 783static void syntax_error_unexpected_ch(unsigned lineno, int ch)
784{ 784{
785 char msg[2]; 785 char msg[2];
786 msg[0] = ch; 786 msg[0] = ch;
787 msg[1] = '\0'; 787 msg[1] = '\0';
788 die_if_script(lineno, "syntax error: unexpected %s", msg); 788 die_if_script(lineno, "syntax error: unexpected %s", ch == EOF ? "EOF" : msg);
789} 789}
790 790
791#if HUSH_DEBUG < 2 791#if HUSH_DEBUG < 2
@@ -5448,10 +5448,17 @@ static struct pipe *parse_stream(char **pstring,
5448 5448
5449 if (heredoc_cnt) { 5449 if (heredoc_cnt) {
5450 syntax_error_unterm_str("here document"); 5450 syntax_error_unterm_str("here document");
5451 xfunc_die(); 5451 goto parse_error;
5452 }
5453 /* end_trigger == '}' case errors out earlier,
5454 * checking only ')' */
5455 if (end_trigger == ')') {
5456 syntax_error_unterm_ch('('); /* exits */
5457 /* goto parse_error; */
5452 } 5458 }
5459
5453 if (done_word(&dest, &ctx)) { 5460 if (done_word(&dest, &ctx)) {
5454 xfunc_die(); 5461 goto parse_error;
5455 } 5462 }
5456 o_free(&dest); 5463 o_free(&dest);
5457 done_pipe(&ctx, PIPE_SEQ); 5464 done_pipe(&ctx, PIPE_SEQ);