From: Lennart Poettering Date: Thu, 21 Sep 2017 17:37:11 +0000 (+0200) Subject: rlimit: don't assume getrlimit() always succeeds X-Git-Tag: v235~60^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4ad3f43ef4cbe73d7d2c4516ab17f0e907dfe16;p=thirdparty%2Fsystemd.git rlimit: don't assume getrlimit() always succeeds 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. --- diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c index ca834df6213..5c41429f01c 100644 --- a/src/basic/rlimit-util.c +++ b/src/basic/rlimit-util.c @@ -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);