From: Ronny Chevalier Date: Fri, 21 Sep 2018 13:59:25 +0000 (+0100) Subject: bus-unit-util: fix parsing of IPAddress{Allow,Deny} X-Git-Tag: v240~649 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afc1feaeba27c814134376374555cf6a1f4dc874;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 134ad63de86..8eea70716c0 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);