summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 16:57:02 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 23:41:42 -0500
commite01ff428993f0c126f010b5625002e6a0a8aff4a (patch)
tree3d26a90ff3c157668dda700094829a1623ba8f5d /src/test
parent4d8629de8bd0f837f99981267d10e71d1f72e47d (diff)
core/load-fragment: avoid allocating 0 bytes when given an invalid command
With a command line like "@/something" we would allocate an array with 0 elements. Avoid that, and add a test too.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-unit-file.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index d6a7d43915..e517f571d6 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -137,6 +137,20 @@ static void test_config_parse_exec(void) {
c1 = c1->command_next;
check_execcommand(c1, "/RValue/slashes2", "///argv0", "r1", NULL, false);
+ log_info("/* honour_argv0, no args */");
+ r = config_parse_exec(NULL, "fake", 3, "section", 1,
+ "LValue", 0, "@/RValue",
+ &c, NULL);
+ assert_se(r == 0);
+ assert_se(c1->command_next == NULL);
+
+ log_info("/* no command, check for bad memory access */");
+ r = config_parse_exec(NULL, "fake", 3, "section", 1,
+ "LValue", 0, " ",
+ &c, NULL);
+ assert_se(r == 0);
+ assert_se(c1->command_next == NULL);
+
log_info("/* ignore && honour_argv0 */");
r = config_parse_exec(NULL, "fake", 4, "section", 1,
"LValue", 0, "-@/RValue///slashes3 argv0a r1",