From afc1feaeba27c814134376374555cf6a1f4dc874 Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Fri, 21 Sep 2018 14:59:25 +0100 Subject: [PATCH] bus-unit-util: fix parsing of IPAddress{Allow,Deny} While the config parser correctly handles the case of multiple IPs, bus_append_cgroup_property was only parsing one IP, and it would fail with "Failed to parse IP address prefix" when given a list of IPs. --- src/shared/bus-unit-util.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 134ad63..8eea707 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -667,13 +667,25 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons return bus_log_create_error(r); } else { - r = in_addr_prefix_from_string_auto(eq, &family, &prefix, &prefixlen); - if (r < 0) - return log_error_errno(r, "Failed to parse IP address prefix: %s", eq); + for (;;) { + _cleanup_free_ char *word = NULL; - r = bus_append_ip_address_access(m, family, &prefix, prefixlen); - if (r < 0) - return bus_log_create_error(r); + r = extract_first_word(&eq, &word, NULL, 0); + if (r == 0) + break; + if (r == -ENOMEM) + return log_oom(); + if (r < 0) + return log_error_errno(r, "Failed to parse %s: %s", field, eq); + + r = in_addr_prefix_from_string_auto(word, &family, &prefix, &prefixlen); + if (r < 0) + return log_error_errno(r, "Failed to parse IP address prefix: %s", word); + + r = bus_append_ip_address_access(m, family, &prefix, prefixlen); + if (r < 0) + return bus_log_create_error(r); + } } r = sd_bus_message_close_container(m); -- 2.7.4