mirror of https://github.com/mirror/busybox.git
awk: fix segfault on for loop syntax error
Parsing "for()" segfaults as awk fails to find loop iteration expressions. Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>1_26_stable
parent
1336052a49
commit
61d5997b58
|
@ -1514,7 +1514,7 @@ static void chain_group(void)
|
||||||
next_token(TC_SEQSTART);
|
next_token(TC_SEQSTART);
|
||||||
n2 = parse_expr(TC_SEMICOL | TC_SEQTERM);
|
n2 = parse_expr(TC_SEMICOL | TC_SEQTERM);
|
||||||
if (t_tclass & TC_SEQTERM) { /* for-in */
|
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);
|
syntax_error(EMSG_UNEXP_TOKEN);
|
||||||
n = chain_node(OC_WALKINIT | VV);
|
n = chain_node(OC_WALKINIT | VV);
|
||||||
n->l.n = n2->l.n;
|
n->l.n = n2->l.n;
|
||||||
|
|
|
@ -316,6 +316,9 @@ testing "awk continue" \
|
||||||
"" \
|
"" \
|
||||||
'BEGIN { if (1) continue; else a = 1 }'
|
'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"
|
# testing "description" "command" "result" "infile" "stdin"
|
||||||
|
|
||||||
exit $FAILCOUNT
|
exit $FAILCOUNT
|
||||||
|
|
Loading…
Reference in New Issue