Noux: fix interpreter argument processing

Don't write a '\0' into the argument buffer if no interpreter argument is
given.

Fixes #368.
This commit is contained in:
Christian Prochaska 2012-09-26 12:29:07 +02:00 committed by Norman Feske
parent 9dc213b296
commit 0a12e262ce
2 changed files with 16 additions and 8 deletions

View File

@ -101,12 +101,18 @@ append config {
<content>
<dir name="home">
<dir name="user">
<inline name=".bash_profile">/home/test_script correct</inline>
<inline name="test_script">#!/bin/make -f
<inline name=".bash_profile">
/home/test_script1 correct
/home/test_script2 "execution of test_script2 succeeded"
</inline>
<inline name="test_script1">#!/bin/make -f
wrong:
@echo "wrong target"
@echo "execution of test_script1 failed"
correct:
@echo "correct target"
@echo "execution of test_script1 succeeded"
</inline>
<inline name="test_script2">#!/bin/bash
echo "$1"
</inline>
</dir>
</dir>

View File

@ -128,10 +128,12 @@ namespace Noux {
/* append interpreter arguments to argument buffer */
size_t interpreter_args_len = eol - interpreter_line_cursor;
Genode::strncpy(&_args[args_buf_cursor],
&binary_addr[interpreter_line_cursor],
interpreter_args_len + 1);
args_buf_cursor += interpreter_args_len + 1;
if (interpreter_args_len > 0) {
Genode::strncpy(&_args[args_buf_cursor],
&binary_addr[interpreter_line_cursor],
interpreter_args_len + 1);
args_buf_cursor += interpreter_args_len + 1;
}
/* append script arguments to argument buffer */
Genode::memcpy(&_args[args_buf_cursor],