All of lore.kernel.org
 help / color / mirror / Atom feed
* Source command with zero-sized files
@ 2015-11-04 15:41 Wjatscheslaw Stoljarski
  2015-11-04 16:51 ` Antony Pavlov
  2015-11-05  6:59 ` [PATCH] hush: Add missing initialize_context() in some places Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Wjatscheslaw Stoljarski @ 2015-11-04 15:41 UTC (permalink / raw)
  To: barebox

Using source command (source <file> or . <file>) on zero-sized files crash barebox.
Can anyone confirm this?

Thanks

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Source command with zero-sized files
  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 ` [PATCH] hush: Add missing initialize_context() in some places Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Antony Pavlov @ 2015-11-04 16:51 UTC (permalink / raw)
  To: Wjatscheslaw Stoljarski; +Cc: barebox

On Wed, 4 Nov 2015 16:41:42 +0100
Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com> wrote:

> Using source command (source <file> or . <file>) on zero-sized files crash barebox.
> Can anyone confirm this?

I can confirm this!

Here is sandbox log:

barebox@barebox sandbox:/ ls -l env/empty
-rwxrwxrwx              0 env/empty
barebox@barebox sandbox:/ source env/empty
Segmentation fault


-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] hush: Add missing initialize_context() in some places
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-11-05  6:59 UTC (permalink / raw)
  To: Barebox List

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-05  7:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] hush: Add missing initialize_context() in some places Sascha Hauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.