summaryrefslogtreecommitdiff
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-16 09:40:07 -0500
commitce4ad5de372ecc8b3f5c935c76c2771440e66b4a (patch)
tree3330c0b09a65b857c1a468038ae34fe66759b40e
parente3880a3d573aa678b36806647661b4de47aaf00d (diff)
downloadsystemd-ce4ad5de372ecc8b3f5c935c76c2771440e66b4a.tar.gz
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. (cherry picked from commit e01ff428993f0c126f010b5625002e6a0a8aff4a) Conflicts: src/core/load-fragment.c src/test/test-unit-file.c
-rw-r--r--src/core/load-fragment.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index e31263ec75..8e785db619 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -581,7 +581,8 @@ int config_parse_exec(const char *unit,
}
found:
- n = new(char*, k + !honour_argv0);
+ /* If seperate_argv0, we'll move first element to path variable */
+ n = new(char*, MAX(k + !honour_argv0, 1u));
if (!n)
return log_oom();