|
|
a19bc6 |
From f1801ded8014054752356123849f86b6746f2a49 Mon Sep 17 00:00:00 2001
|
|
|
a19bc6 |
From: Evgeny Vereshchagin <evvers@ya.ru>
|
|
|
a19bc6 |
Date: Fri, 30 Oct 2015 09:25:12 +0300
|
|
|
a19bc6 |
Subject: [PATCH] core: port config_parse_bounding_set to extract_first_word
|
|
|
a19bc6 |
|
|
|
a19bc6 |
Cherry-picked from: 9ef57298cc57b105c62e2f1dab9ef5837d910604
|
|
|
a19bc6 |
Resolves: #1387398
|
|
|
a19bc6 |
---
|
|
|
a19bc6 |
src/core/load-fragment.c | 29 ++++++++++++++++++-----------
|
|
|
a19bc6 |
1 file changed, 18 insertions(+), 11 deletions(-)
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
|
|
c62b8e |
index 6fc4d745d5..4830d7ad6f 100644
|
|
|
a19bc6 |
--- a/src/core/load-fragment.c
|
|
|
a19bc6 |
+++ b/src/core/load-fragment.c
|
|
|
a19bc6 |
@@ -1028,10 +1028,10 @@ int config_parse_bounding_set(const char *unit,
|
|
|
a19bc6 |
|
|
|
a19bc6 |
uint64_t *capability_bounding_set_drop = data;
|
|
|
a19bc6 |
uint64_t capability_bounding_set;
|
|
|
a19bc6 |
- const char *word, *state;
|
|
|
a19bc6 |
- size_t l;
|
|
|
a19bc6 |
bool invert = false;
|
|
|
a19bc6 |
uint64_t sum = 0;
|
|
|
a19bc6 |
+ const char *prev;
|
|
|
a19bc6 |
+ const char *cur;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
assert(filename);
|
|
|
a19bc6 |
assert(lvalue);
|
|
|
a19bc6 |
@@ -1048,25 +1048,32 @@ int config_parse_bounding_set(const char *unit,
|
|
|
a19bc6 |
* non-inverted everywhere to have a fully normalized
|
|
|
a19bc6 |
* interface. */
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- FOREACH_WORD_QUOTED(word, l, rvalue, state) {
|
|
|
a19bc6 |
- _cleanup_free_ char *t = NULL;
|
|
|
a19bc6 |
+ prev = cur = rvalue;
|
|
|
a19bc6 |
+ for (;;) {
|
|
|
a19bc6 |
+ _cleanup_free_ char *word = NULL;
|
|
|
a19bc6 |
int cap;
|
|
|
a19bc6 |
+ int r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- t = strndup(word, l);
|
|
|
a19bc6 |
- if (!t)
|
|
|
a19bc6 |
+ r = extract_first_word(&cur, &word, NULL, EXTRACT_QUOTES);
|
|
|
a19bc6 |
+ if (r == 0)
|
|
|
a19bc6 |
+ break;
|
|
|
a19bc6 |
+ if (r == -ENOMEM)
|
|
|
a19bc6 |
return log_oom();
|
|
|
a19bc6 |
+ if (r < 0) {
|
|
|
a19bc6 |
+ log_syntax(unit, LOG_ERR, filename, line, r, "Trailing garbage in bounding set, ignoring: %s", prev);
|
|
|
a19bc6 |
+ break;
|
|
|
a19bc6 |
+ }
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- cap = capability_from_name(t);
|
|
|
a19bc6 |
+ cap = capability_from_name(word);
|
|
|
a19bc6 |
if (cap < 0) {
|
|
|
a19bc6 |
- log_syntax(unit, LOG_ERR, filename, line, errno, "Failed to parse capability in bounding set, ignoring: %s", t);
|
|
|
a19bc6 |
+ log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability in bounding set, ignoring: %s", word);
|
|
|
a19bc6 |
+ prev = cur;
|
|
|
a19bc6 |
continue;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
sum |= ((uint64_t) 1ULL) << (uint64_t) cap;
|
|
|
a19bc6 |
+ prev = cur;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
- if (!isempty(state))
|
|
|
a19bc6 |
- log_syntax(unit, LOG_ERR, filename, line, EINVAL,
|
|
|
a19bc6 |
- "Trailing garbage, ignoring.");
|
|
|
a19bc6 |
|
|
|
a19bc6 |
capability_bounding_set = invert ? ~sum : sum;
|
|
|
a19bc6 |
if (*capability_bounding_set_drop && capability_bounding_set)
|