]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rlimit: don't assume getrlimit() always succeeds
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Sep 2017 17:37:11 +0000 (19:37 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Sep 2017 13:28:05 +0000 (15:28 +0200)
In times of seccomp it might very well fail, and given that we return
failures from this function anyway, let's also propagate getrlimit()
failures, just to be safe.

src/basic/rlimit-util.c

index ca834df621311b52c85a5972ea2eb27bb51a54cb..5c41429f01c20496a4672c3842f3ab87f152299e 100644 (file)
@@ -42,7 +42,8 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
 
         /* So we failed to set the desired setrlimit, then let's try
          * to get as close as we can */
-        assert_se(getrlimit(resource, &highest) == 0);
+        if (getrlimit(resource, &highest) < 0)
+                return -errno;
 
         fixed.rlim_cur = MIN(rlim->rlim_cur, highest.rlim_max);
         fixed.rlim_max = MIN(rlim->rlim_max, highest.rlim_max);