From: Michael R Sweet Date: Thu, 20 Jun 2024 12:45:11 +0000 (-0400) Subject: Limit the maximum number of file descriptors to 64k-1 (Issue #989) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a66f419d41843595951e89fff21138113857d04d;p=thirdparty%2Fcups.git Limit the maximum number of file descriptors to 64k-1 (Issue #989) --- diff --git a/CHANGES.md b/CHANGES.md index cd98dd14b7..6a2f18139b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,6 +45,7 @@ Changes in CUPS v2.5b1 (TBA) - Updated `cupsRasterReadPixels` and `cupsRasterWritePixels` to not try reading or writing if the number of bytes passed is 0 (Issue #914) - Updated and documented the MIME typing buffering limit (Issue #925) +- Updated the maximum file descriptor limit for `cupsd` to 64k-1 (Issue #989) - Fixed use-after-free in `cupsdAcceptClient()` when we log warning during error handling (fixes CVE-2023-34241) - Fixed hanging of `lpstat` on Solaris (Issue #156) diff --git a/scheduler/main.c b/scheduler/main.c index 5a63829d2b..62fa8e8dd0 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -503,17 +503,14 @@ main(int argc, /* I - Number of command-line args */ #endif /* HAVE_DBUS_THREADS_INIT */ /* - * Set the maximum number of files... + * Set the maximum number of files, which for practical reasons can be limited + * to the number of TCP port number values (64k-1)... */ getrlimit(RLIMIT_NOFILE, &limit); -#ifdef RLIM_INFINITY - if (limit.rlim_max == RLIM_INFINITY) - MaxFDs = 16384; - else -#endif /* RLIM_INFINITY */ - MaxFDs = limit.rlim_max; + if ((MaxFDs = limit.rlim_max) > 65535) + MaxFDs = 65535; limit.rlim_cur = (rlim_t)MaxFDs;