From e270ec4821be925ebf70460190817b437f589ed9 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jun 28 2022 07:53:42 +0000 Subject: import cups-filters-1.0.35-29.el7_9 --- diff --git a/SOURCES/cups-browsed-remove-entry.patch b/SOURCES/cups-browsed-remove-entry.patch new file mode 100644 index 0000000..5638c32 --- /dev/null +++ b/SOURCES/cups-browsed-remove-entry.patch @@ -0,0 +1,235 @@ +diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c +index 140f863..ff279ee 100644 +--- a/utils/cups-browsed.c ++++ b/utils/cups-browsed.c +@@ -3032,20 +3032,14 @@ create_local_queue (const char *name, + p->name, q->host, q->port); + /* Update q */ + q->num_duplicates ++; +- if (q->status != STATUS_DISAPPEARED) { +- q->status = STATUS_TO_BE_CREATED; +- q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; +- } ++ q->status = STATUS_TO_BE_CREATED; ++ q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; + } else if (q) { + q->duplicate_of = p; + debug_printf("Unconfirmed/disappeared printer %s already available through host %s, port %d, marking that printer duplicate of the newly found one.\n", + p->name, q->host, q->port); +- /* Update p */ +- p->num_duplicates ++; +- if (p->status != STATUS_DISAPPEARED) { +- p->status = STATUS_TO_BE_CREATED; +- p->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; +- } ++ if (q->status == STATUS_UNCONFIRMED) ++ p->num_duplicates ++; + } + } + +@@ -3158,6 +3152,89 @@ remove_bad_chars(const char *str_orig, /* I - Original string */ + return memmove(str, str + i, strlen(str) - i + 1); + } + ++void ++remove_printer_entry(remote_printer_t *p) { ++ remote_printer_t *q, *r; ++ ++ if (p == NULL) { ++ debug_printf ("ERROR: remove_printer_entry(): Supplied printer entry is NULL"); ++ return; ++ } ++ ++ q = NULL; ++ if (p->duplicate_of) { ++ /* "master printer" of this duplicate */ ++ q = p->duplicate_of; ++ q->num_duplicates --; ++ if (q->status != STATUS_DISAPPEARED) { ++ debug_printf("Removing the duplicate printer %s on host %s, port %d, scheduling its master printer %s on host %s, port %d for update, to assure it will have the correct device URI.\n", ++ p->name, p->host, p->port, q->name, q->host, q->port); ++ /* Schedule for update */ ++ q->status = STATUS_TO_BE_CREATED; ++ q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; ++ } ++ q = NULL; ++ } else { ++ /* Check whether this queue has a duplicate from another server and ++ find it */ ++ for (q = (remote_printer_t *)cupsArrayFirst(remote_printers); ++ q; ++ q = (remote_printer_t *)cupsArrayNext(remote_printers)) ++ if (q != p && q->duplicate_of == p) ++ break; ++ } ++ if (q) { ++ /* Remove the data of the disappeared remote printer */ ++ free (p->uri); ++ free (p->host); ++ if (p->ip) free (p->ip); ++ free (p->service_name); ++ free (p->type); ++ free (p->domain); ++ if (p->ppd) free (p->ppd); ++ if (p->model) free (p->model); ++ if (p->ifscript) free (p->ifscript); ++ /* Replace the data with the data of the duplicate printer */ ++ p->uri = strdup(q->uri); ++ p->host = strdup(q->host); ++ p->ip = (q->ip != NULL ? strdup(q->ip) : NULL); ++ p->port = q->port; ++ p->service_name = strdup(q->service_name); ++ p->type = strdup(q->type); ++ p->domain = strdup(q->domain); ++ p->num_duplicates --; ++ if (q->ppd) p->ppd = strdup(q->ppd); else p->ppd = NULL; ++ if (q->model) p->model = strdup(q->model); else p->model = NULL; ++ if (q->ifscript) p->ifscript = strdup(q->ifscript); ++ else p->ifscript = NULL; ++ p->netprinter = q->netprinter; ++ p->is_legacy = q->is_legacy; ++ for (r = (remote_printer_t *)cupsArrayFirst(remote_printers); ++ r; ++ r = (remote_printer_t *)cupsArrayNext(remote_printers)) ++ if (r->duplicate_of == q) ++ r->duplicate_of = p; ++ /* Schedule this printer for updating the CUPS queue */ ++ p->status = STATUS_TO_BE_CREATED; ++ p->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; ++ /* Schedule the duplicate printer entry for removal */ ++ q->status = STATUS_DISAPPEARED; ++ q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; ++ ++ debug_printf("Printer %s diasappeared, replacing by backup on host %s, port %d with URI %s.\n", ++ p->name, p->host, p->port, p->uri); ++ } else { ++ ++ /* Schedule CUPS queue for removal */ ++ p->status = STATUS_DISAPPEARED; ++ p->timeout = time(NULL) + TIMEOUT_REMOVE; ++ ++ debug_printf("Printer %s (Host: %s, Port: %d, URI: %s) disappeared and no duplicate available, or a duplicate of another printer, removing entry.\n", ++ p->name, p->host, p->port, p->uri); ++ ++ } ++} ++ + gboolean handle_cups_queues(gpointer unused) { + remote_printer_t *p, *q; + http_t *http, *remote_http; +@@ -3227,11 +3304,9 @@ gboolean handle_cups_queues(gpointer unused) { + break; + + /* Queue not reported again by Bonjour, remove it */ +- p->status = STATUS_DISAPPEARED; +- p->timeout = current_time + TIMEOUT_IMMEDIATELY; +- + debug_printf("No remote printer named %s available, removing entry from previous session.\n", + p->name); ++ remove_printer_entry(p); + + /* Bonjour has reported this printer as disappeared or we have replaced + this printer by another one */ +@@ -3818,8 +3893,7 @@ gboolean handle_cups_queues(gpointer unused) { + /* Remove a queue based on a legacy CUPS broadcast when the + broadcast timeout expires without a new broadcast of this + queue from the server */ +- p->status = STATUS_DISAPPEARED; +- p->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; ++ remove_printer_entry(p); + } else + p->timeout = (time_t) -1; + +@@ -4700,7 +4774,7 @@ static void browse_callback( + + /* A service (remote printer) has disappeared */ + case AVAHI_BROWSER_REMOVE: { +- remote_printer_t *p, *q, *r; ++ remote_printer_t *p; + + /* Ignore events from the local machine */ + if (flags & AVAHI_LOOKUP_RESULT_LOCAL) +@@ -4723,82 +4797,7 @@ static void browse_callback( + !strcasecmp(p->domain, domain)) + break; + if (p) { +- q = NULL; +- if (p->duplicate_of) { +- /* "master printer" of this duplicate */ +- q = p->duplicate_of; +- q->num_duplicates --; +- if (q->status != STATUS_DISAPPEARED) { +- debug_printf("Removing the duplicate printer %s on host %s, port %d, scheduling its master printer %s on host %s, port %d for update, to assure it will have the correct device URI.\n", +- p->name, p->host, p->port, q->name, q->host, q->port); +- /* Schedule for update */ +- q->status = STATUS_TO_BE_CREATED; +- q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; +- } +- q = NULL; +- } else { +- /* Check whether this queue has a duplicate from another server and +- find it */ +- for (q = (remote_printer_t *)cupsArrayFirst(remote_printers); +- q; +- q = (remote_printer_t *)cupsArrayNext(remote_printers)) +- if (!strcasecmp(q->name, p->name) && +- (strcasecmp(q->host, p->host) || q->port != p->port) && +- q->duplicate_of == p) +- break; +- } +- if (q) { +- /* Remove the data of the disappeared remote printer */ +- free (p->uri); +- free (p->host); +- if (p->ip) free (p->ip); +- free (p->service_name); +- free (p->type); +- free (p->domain); +- if (p->ppd) free (p->ppd); +- if (p->model) free (p->model); +- if (p->ifscript) free (p->ifscript); +- /* Replace the data with the data of the duplicate printer */ +- p->uri = strdup(q->uri); +- p->host = strdup(q->host); +- p->ip = (q->ip != NULL ? strdup(q->ip) : NULL); +- p->port = q->port; +- p->service_name = strdup(q->service_name); +- p->type = strdup(q->type); +- p->domain = strdup(q->domain); +- p->num_duplicates --; +- if (q->ppd) p->ppd = strdup(q->ppd); +- if (q->model) p->model = strdup(q->model); +- if (q->ifscript) p->ifscript = strdup(q->ifscript); +- p->netprinter = q->netprinter; +- p->is_legacy = q->is_legacy; +- for (r = (remote_printer_t *)cupsArrayFirst(remote_printers); +- r; +- r = (remote_printer_t *)cupsArrayNext(remote_printers)) +- if (!strcasecmp(p->name, r->name) && +- (strcasecmp(p->host, r->host) || p->port != r->port) && +- r->duplicate_of == q) +- r->duplicate_of = p; +- /* Schedule this printer for updating the CUPS queue */ +- p->status = STATUS_TO_BE_CREATED; +- p->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; +- /* Schedule the duplicate printer entry for removal */ +- q->status = STATUS_DISAPPEARED; +- q->timeout = time(NULL) + TIMEOUT_IMMEDIATELY; +- +- debug_printf("Printer %s diasappeared, replacing by backup on host %s, port %d with URI %s.\n", +- p->name, p->host, p->port, p->uri); +- } else { +- +- /* Schedule CUPS queue for removal */ +- p->status = STATUS_DISAPPEARED; +- p->timeout = time(NULL) + TIMEOUT_REMOVE; +- +- debug_printf("Printer %s (Host: %s, Port: %d, URI: %s) disappeared and no duplicate available, or a duplicate of another printer, removing entry.\n", +- p->name, p->host, p->port, p->uri); +- +- } +- ++ remove_printer_entry(p); + debug_printf("Bonjour IDs: Service name: \"%s\", Service type: \"%s\", Domain: \"%s\"\n", + p->service_name, p->type, p->domain); + diff --git a/SPECS/cups-filters.spec b/SPECS/cups-filters.spec index 5722551..9635a4a 100644 --- a/SPECS/cups-filters.spec +++ b/SPECS/cups-filters.spec @@ -4,7 +4,7 @@ Summary: OpenPrinting CUPS filters and backends Name: cups-filters Version: 1.0.35 -Release: 28%{?dist} +Release: 29%{?dist} # For a breakdown of the licensing, see COPYING file # GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*, @@ -52,6 +52,8 @@ Patch14: 0001-cups-browsed-Removing-CUPS-array-element-from-within.patch Patch15: cups-browsed-memory-leaks.patch # 1812635 - RHEL 7.7. cups-browsed segfaults on shutdown Patch16: cups-filters-deleted-master.patch +# 1894301 - cups-browsed segfaults when accessing freed master queue in print queue cluster +Patch17: cups-browsed-remove-entry.patch Requires: cups-filters-libs%{?_isa} = %{version}-%{release} @@ -194,6 +196,9 @@ cp %{SOURCE5} . # 1812635 - RHEL 7.7. cups-browsed segfaults on shutdown %patch16 -p1 -b .deleted-master +# 1894301 - cups-browsed segfaults when accessing freed master queue in print queue cluster +%patch17 -p1 -b .remove-entry + %build # work-around Rpath ./autogen.sh @@ -301,6 +306,9 @@ fi %{_libdir}/libfontembed.so %changelog +* Tue May 17 2022 Zdenek Dohnal - 1.0.35-29 +- 1894301 - cups-browsed segfaults when accessing freed master queue in print queue cluster + * Tue Mar 24 2020 Zdenek Dohnal - 1.0.35-28 - 1812635 - RHEL 7.7. cups-browsed segfaults on shutdown