]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Check for negative max-fds limit and set to 65535. Fixes a test hang.
authorMichael R Sweet <msweet@msweet.org>
Fri, 20 Sep 2024 15:33:48 +0000 (11:33 -0400)
committerMichael R Sweet <msweet@msweet.org>
Fri, 20 Sep 2024 15:33:48 +0000 (11:33 -0400)
scheduler/client.c
scheduler/main.c

index 9c2f1ef81487a17cb7f4d1657b79948a67ac238a..ab3d835e25045d9007ef95d3080e5453ba226fa5 100644 (file)
@@ -68,7 +68,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
   * Make sure we don't have a full set of clients already...
   */
 
-  if (cupsArrayGetCount(Clients) == MaxClients)
+  if (MaxClients && cupsArrayGetCount(Clients) >= MaxClients)
     return;
 
   cupsdSetBusyState(1);
index 62fa8e8dd08f0fe1da29d518aa6422cbe250e818..be2e5f13f988ac5ac5f64c5d7c10c3b7315ff445 100644 (file)
@@ -507,10 +507,16 @@ main(int  argc,                           /* I - Number of command-line args */
   * to the number of TCP port number values (64k-1)...
   */
 
-  getrlimit(RLIMIT_NOFILE, &limit);
-
-  if ((MaxFDs = limit.rlim_max) > 65535)
+  if (getrlimit(RLIMIT_NOFILE, &limit))
+  {
+    // This should never happen but if it does choose a safe upper limit...
+    perror("getrlimit");
+    MaxFDs = 256;
+  }
+  else if ((MaxFDs = limit.rlim_max) > 65535 || MaxFDs <= 0)
+  {
     MaxFDs = 65535;
+  }
 
   limit.rlim_cur = (rlim_t)MaxFDs;