]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Check for RLIMIT_NOFILE before trying to use it.
authorDarren Tucker <dtucker@dtucker.net>
Mon, 2 Aug 2021 08:56:29 +0000 (18:56 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 2 Aug 2021 08:56:29 +0000 (18:56 +1000)
sftp-server.c

index 4972b2a65dc53125b76d2794fa7e3515af320c77..c89c1f4249139e8a910d7fa9a9dd43be525c7120 100644 (file)
@@ -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