]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: Parse infinity properly for memory protections
authorMichal Koutný <mkoutny@suse.com>
Wed, 24 Jun 2020 18:40:02 +0000 (20:40 +0200)
committerMichal Koutný <mkoutny@suse.com>
Wed, 24 Jun 2020 21:16:06 +0000 (23:16 +0200)
This fixes commit db2b8d2e2895010f3443a589c9c1f1dfb25256a6 that
rectified parsing empty values but broke parsing explicit infinity.
Intended parsing semantics will be captured in a testcase in a follow up
commit.

Ref: #16248

src/core/load-fragment.c

index c3186f38243897f478233f36643e0e22ebb60de8..636ff654768dcb6f7c5fdcc9272fd05d64bbad1b 100644 (file)
@@ -3427,13 +3427,12 @@ int config_parse_memory_limit(
         uint64_t bytes = CGROUP_LIMIT_MAX;
         int r;
 
-        if (STR_IN_SET(lvalue, "DefaultMemoryLow",
-                               "DefaultMemoryMin",
-                               "MemoryLow",
-                               "MemoryMin"))
+        if (isempty(rvalue) && STR_IN_SET(lvalue, "DefaultMemoryLow",
+                                                  "DefaultMemoryMin",
+                                                  "MemoryLow",
+                                                  "MemoryMin"))
                 bytes = CGROUP_LIMIT_MIN;
-
-        if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
+        else if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
 
                 r = parse_permille(rvalue);
                 if (r < 0) {