From c4ad3f43ef4cbe73d7d2c4516ab17f0e907dfe16 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Sep 2017 19:37:11 +0200 Subject: [PATCH] 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. --- src/basic/rlimit-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c index ca834df..5c41429 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); -- 2.7.4