Skip to contentSkip to conversation

Source command with zero-sized files

PATCH New Wjatscheslaw Stoljarski 3 participants 3 messages Nov 4, 2015 – Nov 5, 2015

lore
Share & tools
lore
#1 lore raw
Quoted 2 lines · On Wed, 4 Nov 2015 16:41:42 +0100 Wjatscheslaw Stoljarski…

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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

PATCH 1/1 hush: Add missing initialize_context() in some places

In reply to Wjatscheslaw Stoljarski

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

---

This patch should fix this issue.

 common/hush.c | 6 ++++++
 1 file changed, 6 insertions(+)
common/hush.c +6 -0
index abe8713..084dd85 100644
@@ -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;
 
Signature · 7 lines
2.6.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox