diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-01 21:38:46 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-02 10:37:33 +0200 |
commit | ebde5ae5ac1fa96211b974f444ceed4bc39c3d49 (patch) | |
tree | 5b5e5e5c87e7085b33447d27394fc32f96497e86 /common | |
parent | deadc3dd7e18a4d177aabcad6df9045f69e53f2b (diff) | |
download | barebox-ebde5ae5ac1fa96211b974f444ceed4bc39c3d49.tar.gz barebox-ebde5ae5ac1fa96211b974f444ceed4bc39c3d49.tar.xz |
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>
Diffstat (limited to 'common')
-rw-r--r-- | common/hush.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/hush.c b/common/hush.c index 053d9a583e..f432c0cae4 100644 --- a/common/hush.c +++ b/common/hush.c @@ -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 */ |