summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-04 20:16:14 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-04 20:16:14 +0100
commita6bff4a7428b9539d85618e3c91fcb60be93f3fa (patch)
tree5ff4f4ade22fa5768dd0d061d345e18613541b7f /src
parent50bcc7f45c52ca0cef876bc42ef7af6b04563106 (diff)
parent7b2313f5caa3c48c23724cb9f575e2406c04edc4 (diff)
Merge pull request #1761 from ssahani/word
core: parse socket port to extract_first_word
Diffstat (limited to 'src')
-rw-r--r--src/core/load-fragment.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 5949749374..43cdd1f4c4 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1582,8 +1582,7 @@ int config_parse_service_sockets(
void *userdata) {
Service *s = data;
- const char *word, *state;
- size_t l;
+ const char *p;
int r;
assert(filename);
@@ -1591,14 +1590,21 @@ int config_parse_service_sockets(
assert(rvalue);
assert(data);
- FOREACH_WORD_QUOTED(word, l, rvalue, state) {
- _cleanup_free_ char *t = NULL, *k = NULL;
+ p = rvalue;
+ for(;;) {
+ _cleanup_free_ char *word = NULL, *t = NULL, *k = NULL;
- t = strndup(word, l);
- if (!t)
+ r = extract_first_word(&p, &word, NULL, 0);
+ if (r == 0)
+ break;
+ if (r == -ENOMEM)
return log_oom();
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue);
+ break;
+ }
- r = unit_name_printf(UNIT(s), t, &k);
+ r = unit_name_printf(UNIT(s), word, &k);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve specifiers, ignoring: %m");
continue;
@@ -1617,8 +1623,6 @@ int config_parse_service_sockets(
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k);
}
- if (!isempty(state))
- log_syntax(unit, LOG_ERR, filename, line, 0, "Trailing garbage, ignoring.");
return 0;
}