mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ukl@pengutronix.de
Subject: [PATCH] hush: bail out of scripts on syntax error
Date: Wed,  2 May 2012 09:12:46 +0200	[thread overview]
Message-ID: <1335942766-31064-1-git-send-email-s.hauer@pengutronix.de> (raw)

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>
---
 common/hush.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/hush.c b/common/hush.c
index 053d9a5..f432c0c 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 */
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2012-05-02  7:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-02  7:12 Sascha Hauer [this message]
2012-05-02  7:36 ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335942766-31064-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ukl@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox