mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] hush: Add missing initialize_context() in some places
Date: Thu,  5 Nov 2015 07:59:38 +0100	[thread overview]
Message-ID: <1446706778-30658-1-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20151104154142.GA27677@gmail.com>

Before a context can be used it must be initialized. This was forgotten
in several places. Add the missing calls to initialize_context().
This fixes crashes when sourcing empty files

Reported-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---

This patch should fix this issue.

 common/hush.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/hush.c b/common/hush.c
index abe8713..084dd85 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -814,6 +814,8 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi)
 		char * str = NULL;
 		struct p_context ctx1;
 
+		initialize_context(&ctx1);
+
 		str = make_string((child->argv + i));
 		rcode = parse_string_outer(&ctx1, str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING);
 		release_context(&ctx1);
@@ -1866,6 +1868,8 @@ int run_command(const char *cmd)
 	struct p_context ctx;
 	int ret;
 
+	initialize_context(&ctx);
+
 	ret = parse_string_outer(&ctx, cmd, FLAG_PARSE_SEMICOLON);
 	release_context(&ctx);
 
@@ -1889,6 +1893,8 @@ static int source_script(const char *path, int argc, char *argv[])
 	char *script;
 	int ret;
 
+	initialize_context(&ctx);
+
 	ctx.global_argc = argc;
 	ctx.global_argv = argv;
 
-- 
2.6.1


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

      parent reply	other threads:[~2015-11-05  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 15:41 Source command with zero-sized files Wjatscheslaw Stoljarski
2015-11-04 16:51 ` Antony Pavlov
2015-11-05  6:59 ` Sascha Hauer [this message]

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=1446706778-30658-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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