[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] awk: Fix segfault on for loop syntax error
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2016-10-24 0:11:07
Message-ID: CAK1hOcOAaDFi=xGmV8M+Hc8T_nHnF8AuYaRWFiouWFmd1BeJXQ () mail ! gmail ! com
[Download RAW message or body]
Applied, thanks!
On Sat, Oct 15, 2016 at 3:45 PM, Brian Foley <bpfoley@google.com> wrote:
> Parsing "for()" segfaults as awk fails to find loop iteration expressions.
>
> Signed-off-by: Brian Foley <bpfoley@google.com>
> ---
> editors/awk.c | 2 +-
> testsuite/awk.tests | 3 +++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/editors/awk.c b/editors/awk.c
> index d0269b9..685e8be 100644
> --- a/editors/awk.c
> +++ b/editors/awk.c
> @@ -1514,7 +1514,7 @@ static void chain_group(void)
> next_token(TC_SEQSTART);
> n2 = parse_expr(TC_SEMICOL | TC_SEQTERM);
> if (t_tclass & TC_SEQTERM) { /* for-in */
> - if ((n2->info & OPCLSMASK) != OC_IN)
> + if (!n2 || (n2->info & OPCLSMASK) != OC_IN)
> syntax_error(EMSG_UNEXP_TOKEN);
> n = chain_node(OC_WALKINIT | VV);
> n->l.n = n2->l.n;
> diff --git a/testsuite/awk.tests b/testsuite/awk.tests
> index adab4ae..82937bc 100755
> --- a/testsuite/awk.tests
> +++ b/testsuite/awk.tests
> @@ -316,6 +316,9 @@ testing "awk continue" \
> "" \
> 'BEGIN { if (1) continue; else a = 1 }'
>
> +testing "awk handles invalid for loop" \
> + "awk '{ for() }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" ""
> +
> # testing "description" "command" "result" "infile" "stdin"
>
> exit $FAILCOUNT
> --
> 2.7.4
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic