hush: bail out of scripts on syntax error
On a systax error we have to bail out of the shell instead of setting inp->p to NULL and crash barebox with a NULL pointer deref. This only happened in scripts. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> This fixes the problem I had (i.e. a boot loop caused by a stray fi in /env/bin/init). Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
deadc3dd7e
commit
ebde5ae5ac
|
@ -1436,6 +1436,7 @@ static int parse_stream_outer(struct p_context *ctx, struct in_str *inp, int fla
|
|||
rcode = parse_stream(&temp, ctx, inp, '\n');
|
||||
if (rcode != 1 && ctx->old_flag != 0) {
|
||||
syntax();
|
||||
return 1;
|
||||
}
|
||||
if (rcode != 1 && ctx->old_flag == 0) {
|
||||
done_word(&temp, ctx);
|
||||
|
@ -1460,8 +1461,9 @@ static int parse_stream_outer(struct p_context *ctx, struct in_str *inp, int fla
|
|||
inp->__promptme = 1;
|
||||
temp.nonnull = 0;
|
||||
temp.quote = 0;
|
||||
inp->p = NULL;
|
||||
free_pipe_list(ctx->list_head,0);
|
||||
b_free(&temp);
|
||||
return 1;
|
||||
}
|
||||
b_free(&temp);
|
||||
} while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP)); /* loop on syntax errors, return on EOF */
|
||||
|
|
Loading…
Reference in New Issue