]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge fix for #719 into 2.4.x
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 6 Jun 2023 12:38:02 +0000 (14:38 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 6 Jun 2023 12:38:02 +0000 (14:38 +0200)
CHANGES.md
cups/dest.c

index f01a899e171156f2fce075d5d609d359dc175b7f..b0e0349a913c50f75c2b25e14237521c97cc3106 100644 (file)
@@ -4,6 +4,9 @@ CHANGES - OpenPrinting CUPS 2.4.3 - 2023-06-01
 Changes in CUPS v2.4.4 (TBA)
 ---------------------------
 
+- Fix segfault in `cupsGetNamedDest()` when trying to get default printer, but
+  the default printer is not set (Issue #719)
+
 
 Changes in CUPS v2.4.3 (2023-06-01)
 -----------------------------------
index 741aae06314c6e819ac3490733555f2e8b8e1767..da775a390155d83d12cc05f2a355bf77a620be0c 100644 (file)
@@ -1836,49 +1836,52 @@ cupsGetNamedDest(http_t     *http,      /* I - Connection to server or @code CUPS_HTT
 
   if (!_cupsGetDests(http, op, dest_name, &dest, 0, 0))
   {
-      _cups_namedata_t  data;           /* Callback data */
+    _cups_namedata_t  data;           /* Callback data */
 
-      DEBUG_puts("1cupsGetNamedDest: No queue found for printer, looking on network...");
+    data.name = dest_name;
+    data.dest = NULL;
 
-      data.name = dest_name;
-      data.dest = NULL;
+    if (data.name)
+    {
+      DEBUG_puts("1cupsGetNamedDest: No queue found for printer, looking on network...");
 
       cupsEnumDests(0, 1000, NULL, 0, 0, (cups_dest_cb_t)cups_name_cb, &data);
+    }
 
-      if (!data.dest)
+    if (!data.dest)
+    {
+      switch (set_as_default)
       {
-       switch (set_as_default)
-       {
-         default :
-             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("The printer or class does not exist."), 1);
-             break;
-
-         case 1 : /* Set from env vars */
-             if (getenv("LPDEST"))
-               _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("LPDEST environment variable names default destination that does not exist."), 1);
-             else if (getenv("PRINTER"))
-               _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("PRINTER environment variable names default destination that does not exist."), 1);
-             else
-               _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
-             break;
+       default :
+           _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("The printer or class does not exist."), 1);
+           break;
+
+       case 1 : /* Set from env vars */
+           if (getenv("LPDEST"))
+             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("LPDEST environment variable names default destination that does not exist."), 1);
+           else if (getenv("PRINTER"))
+             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("PRINTER environment variable names default destination that does not exist."), 1);
+           else
+             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
+           break;
 
-         case 2 : /* Set from ~/.cups/lpoptions */
-             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("~/.cups/lpoptions file names default destination that does not exist."), 1);
-             break;
+       case 2 : /* Set from ~/.cups/lpoptions */
+           _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("~/.cups/lpoptions file names default destination that does not exist."), 1);
+           break;
 
-         case 3 : /* Set from /etc/cups/lpoptions */
-             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("/etc/cups/lpoptions file names default destination that does not exist."), 1);
-             break;
+       case 3 : /* Set from /etc/cups/lpoptions */
+           _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("/etc/cups/lpoptions file names default destination that does not exist."), 1);
+           break;
 
-         case 4 : /* Set from server */
-             _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
-             break;
-       }
+       case 4 : /* Set from server */
+           _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
+           break;
+      }
 
       return (NULL);
-      }
+    }
 
-      dest = data.dest;
+    dest = data.dest;
   }
 
   DEBUG_printf(("1cupsGetNamedDest: Got dest=%p", (void *)dest));