summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/load-fragment.c6
-rw-r--r--src/test/test-unit-file.c21
2 files changed, 26 insertions, 1 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 33d9e2714a..3865017d97 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -595,7 +595,11 @@ int config_parse_exec(
skip = separate_argv0 + ignore;
/* skip special chars in the beginning */
- assert(skip < l);
+ if (l <= skip) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Empty path in command line, ignoring: %s", rvalue);
+ r = 0;
+ goto fail;
+ }
} else if (strneq(word, ";", MAX(l, 1U)))
/* new commandline */
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index f3f6c29f75..03ca70a493 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -317,6 +317,27 @@ static void test_config_parse_exec(void) {
assert_se(r == 0);
assert_se(c1->command_next == NULL);
+ log_info("/* invalid space between modifiers */");
+ r = config_parse_exec(NULL, "fake", 4, "section", 1,
+ "LValue", 0, "- /path",
+ &c, NULL);
+ assert_se(r == 0);
+ assert_se(c1->command_next == NULL);
+
+ log_info("/* only modifiers, no path */");
+ r = config_parse_exec(NULL, "fake", 4, "section", 1,
+ "LValue", 0, "-",
+ &c, NULL);
+ assert_se(r == 0);
+ assert_se(c1->command_next == NULL);
+
+ log_info("/* empty argument, reset */");
+ r = config_parse_exec(NULL, "fake", 4, "section", 1,
+ "LValue", 0, "",
+ &c, NULL);
+ assert_se(r == 0);
+ assert_se(c == NULL);
+
exec_command_free_list(c);
}