From 1e11fb24066f3fc259ee30db3dbb2a3127e05956 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Mon, 2 Aug 2021 18:56:29 +1000 Subject: [PATCH] Check for RLIMIT_NOFILE before trying to use it. --- sftp-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sftp-server.c b/sftp-server.c index 4972b2a65..c89c1f424 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -1491,13 +1491,13 @@ process_extended_limits(u_int32_t id) struct sshbuf *msg; int r; uint64_t nfiles = 0; -#ifdef HAVE_GETRLIMIT +#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) struct rlimit rlim; #endif debug("request %u: limits", id); -#ifdef HAVE_GETRLIMIT +#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rlim) != -1 && rlim.rlim_cur > 5) nfiles = rlim.rlim_cur - 5; /* stdio(3) + syslog + spare */ #endif