diff options
-rw-r--r-- | src/journal-remote/journal-remote.c | 20 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 16 | ||||
-rw-r--r-- | src/shared/install.c | 19 |
3 files changed, 31 insertions, 24 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index a2c49b8b4d..44550532b6 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -1255,6 +1255,7 @@ static int parse_argv(int argc, char *argv[]) { }; int c, r; + const char *p; bool type_a, type_b; assert(argc >= 0); @@ -1415,18 +1416,21 @@ static int parse_argv(int argc, char *argv[]) { case ARG_GNUTLS_LOG: { #ifdef HAVE_GNUTLS - const char *word, *state; - size_t size; + p = optarg; + for (;;) { + _cleanup_free_ char *word = NULL; - FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) { - char *cat; + r = extract_first_word(&p, &word, ",", 0); + if (r < 0) + return log_error_errno(r, "Failed to parse --gnutls-log= argument: %m"); - cat = strndup(word, size); - if (!cat) - return log_oom(); + if (r == 0) + break; - if (strv_consume(&arg_gnutls_log, cat) < 0) + if (strv_push(&arg_gnutls_log, word) < 0) return log_oom(); + + word = NULL; } break; #else diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 8140cda141..44f08ab1b4 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -387,6 +387,7 @@ static int parse_argv(int argc, char *argv[]) { }; int c, r; + const char *p; uint64_t plus = 0, minus = 0; bool mask_all_settings = false, mask_no_settings = false; @@ -524,15 +525,16 @@ static int parse_argv(int argc, char *argv[]) { case ARG_CAPABILITY: case ARG_DROP_CAPABILITY: { - const char *state, *word; - size_t length; + p = optarg; + for(;;) { + _cleanup_free_ char *t = NULL; - FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) { - _cleanup_free_ char *t; + r = extract_first_word(&p, &t, ",", 0); + if (r < 0) + return log_error_errno(r, "Failed to parse capability %s.", t); - t = strndup(word, length); - if (!t) - return log_oom(); + if (r == 0) + break; if (streq(t, "all")) { if (c == ARG_CAPABILITY) diff --git a/src/shared/install.c b/src/shared/install.c index c74efede76..b7d1d22505 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -929,8 +929,6 @@ static int config_parse_also( void *data, void *userdata) { - size_t l; - const char *word, *state; InstallContext *c = data; UnitFileInstallInfo *i = userdata; @@ -938,13 +936,18 @@ static int config_parse_also( assert(lvalue); assert(rvalue); - FOREACH_WORD_QUOTED(word, l, rvalue, state) { - _cleanup_free_ char *n; + for(;;) { + _cleanup_free_ char *n = NULL; int r; - n = strndup(word, l); - if (!n) - return -ENOMEM; + r = extract_first_word(&rvalue, &n, NULL, 0); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse config %s, ignoring.", rvalue); + return 0; + } + + if (r == 0) + break; r = install_info_add(c, n, NULL); if (r < 0) @@ -954,8 +957,6 @@ static int config_parse_also( if (r < 0) return r; } - if (!isempty(state)) - log_syntax(unit, LOG_ERR, filename, line, 0, "Trailing garbage, ignoring."); return 0; } |