diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-31 03:28:37 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-31 08:56:03 -0400 |
commit | b2fadec6048adb3596f2633cb7fe7a49f5937a18 (patch) | |
tree | 8969997ed3730146ff98774b14b3dcd65392c4df /src/shared/strv.c | |
parent | a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8 (diff) |
Properly report invalid quoted strings
$ systemd-analyze verify trailing-g.service
[./trailing-g.service:2] Trailing garbage, ignoring.
trailing-g.service lacks ExecStart setting. Refusing.
Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument.
Failed to create trailing-g.service/start: Invalid argument
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r-- | src/shared/strv.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c index 0ac66b927c..6448f3170f 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -231,7 +231,7 @@ char **strv_split(const char *s, const char *separator) { return r; } -char **strv_split_quoted(const char *s) { +int strv_split_quoted(char ***t, const char *s) { const char *word, *state; size_t l; unsigned n, i; @@ -242,26 +242,27 @@ char **strv_split_quoted(const char *s) { n = 0; FOREACH_WORD_QUOTED(word, l, s, state) n++; - if (*state) + if (!isempty(state)) /* bad syntax */ - return NULL; + return -EINVAL; r = new(char*, n+1); if (!r) - return NULL; + return -ENOMEM; i = 0; FOREACH_WORD_QUOTED(word, l, s, state) { r[i] = cunescape_length(word, l); if (!r[i]) { strv_free(r); - return NULL; + return -ENOMEM; } i++; } r[i] = NULL; - return r; + *t = r; + return 0; } char **strv_split_newlines(const char *s) { |