When an empty string is passed, then that turns into no elements into
the input array, and thus no return buffer is created, leading to
dereference null to assign the trailing null. In such situation,
create an empty string as return value.
---
daemon/echo-daemon.c | 8 ++++++++
generator/actions.ml | 4 +++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/daemon/echo-daemon.c b/daemon/echo-daemon.c
index c805819..d8f1028 100644
--- a/daemon/echo-daemon.c
+++ b/daemon/echo-daemon.c
@@ -65,6 +65,14 @@ do_echo_daemon (char *const *argv)
argv++;
}
+ if (NULL == out) {
+ /* No strings, so create a new empty array. */
+ out = malloc (sizeof (char *));
+ if (NULL == out) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+ }
/* NULL terminate the output */
out[out_len] = '\0';
diff --git a/generator/actions.ml b/generator/actions.ml
index 9570d9b..bb95f7a 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -7210,7 +7210,9 @@ was built (see C<appliance/kmod.whitelist.in> in the
source)." };
proc_nr = Some 195;
tests = [
InitNone, Always, TestResultString (
- [["echo_daemon"; "This is a test"]], "This is a
test"), []
+ [["echo_daemon"; "This is a test"]], "This is a
test"), [];
+ InitNone, Always, TestResultString (
+ [["echo_daemon"; ""]], ""), [];
];
shortdesc = "echo arguments back to the client";
longdesc = "\
--
1.9.3