diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2015-04-22 23:09:43 +0100 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-05-04 14:01:33 -0400 |
commit | 506d0b092e912f51bee87add6e2cf83a5be6f8ee (patch) | |
tree | 09def87feee56d7e955e33c7282158ccf63db4b5 | |
parent | 0485a848a38ad5a0e61b4671f3b36d35e3fdd069 (diff) |
util: Fix assertion in split() on missing '
When parsing a unit with a trailing slash after an escaped line break, like
ExecStart=/bin/echo 'foo \
bar'
the split() function (through config_parse()) asserted and crashed pid 1:
Assertion 'current[*l + 1] == quotechars[0]' failed at ../src/shared/util.c:583, function split(). Aborting.
Fix this by returning an error in this case ("trailing garbage").
Add corresponding test case. Also fix the missing "unit" argument of
config_parse_exec() in the comment.
https://launchpad.net/bugs/1447243
-rw-r--r-- | src/shared/util.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 17ae61f90b..befe019588 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -393,13 +393,12 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo char quotechars[2] = {*current, '\0'}; *l = strcspn_escaped(current + 1, quotechars); - if (current[*l + 1] == '\0' || + if (current[*l + 1] == '\0' || current[*l + 1] != quotechars[0] || (current[*l + 2] && !strchr(separator, current[*l + 2]))) { /* right quote missing or garbage at the end */ *state = current; return NULL; } - assert(current[*l + 1] == quotechars[0]); *state = current++ + *l + 2; } else if (quoted) { *l = strcspn_escaped(current, separator); |