import cups-filters-1.20.0-20.el8

This commit is contained in:
CentOS Sources 2020-11-03 06:56:25 -05:00 committed by Andrew Lukoshko
parent 718e8cdb99
commit 0ab673c10a
3 changed files with 303 additions and 1 deletions

View File

@ -0,0 +1,63 @@
diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
index 80bde46..54ae2ac 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -439,6 +439,19 @@ static remote_printer_t
#define HAVE_CUPS_1_6 1
#endif
+/*
+ * Option 'printer-is-shared' cannot be set on remote CUPS
+ * queue and requests for setting it ends with error since
+ * 2.1.1. Define HAVE_CUPS_2_2 to do not send IPP request
+ * for setting 'printer-is-shared' option on remote CUPS queues
+ * for newer versions of CUPS.
+ */
+#if (CUPS_VERSION_MAJOR > 2) || (CUPS_VERSION_MINOR > 1)
+#define HAVE_CUPS_2_2 1
+#else
+#define HAVE_CUPS_2_2 0
+#endif
+
/*
* CUPS 1.6 makes various structures private and
* introduces these ippGet and ippSet functions
@@ -4394,7 +4407,20 @@ gboolean update_cups_queues(gpointer unused) {
num_options, &options);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
- ippDelete(cupsDoRequest(http, request, "/admin/"));
+ /*
+ * Do IPP request for printer-is-shared option only when we have
+ * network printer or if we have remote CUPS queue, do IPP request
+ * only if we have CUPS older than 2.2.
+ * When you have remote queue, clean up and break from the loop.
+ */
+ if (p->netprinter != 0 || !HAVE_CUPS_2_2)
+ ippDelete(cupsDoRequest(http, request, "/admin/"));
+ else
+ {
+ ippDelete(request);
+ cupsFreeOptions(num_options, options);
+ break;
+ }
cupsFreeOptions(num_options, options);
if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE) {
debug_printf("Unable change printer-is-shared bit to %s (%s)!\n",
@@ -4803,7 +4829,15 @@ gboolean update_cups_queues(gpointer unused) {
}
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
- ippDelete(cupsDoRequest(http, request, "/admin/"));
+ /*
+ * Do IPP request for printer-is-shared option only when we have
+ * network printer or if we have remote CUPS queue, do IPP request
+ * only if we have CUPS older than 2.2.
+ */
+ if (p->netprinter != 0 || !HAVE_CUPS_2_2)
+ ippDelete(cupsDoRequest(http, request, "/admin/"));
+ else
+ ippDelete(request);
cupsFreeOptions(num_options, options);
if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE)
debug_printf("Unable to set printer-is-shared bit to false (%s)!\n",

View File

@ -0,0 +1,219 @@
diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c
index 3bc4d8a..44d9313 100644
--- a/cupsfilters/ppdgenerator.c
+++ b/cupsfilters/ppdgenerator.c
@@ -752,12 +752,17 @@ load_opt_strings_catalog(const char *location, cups_array_t *options)
2: "..." = "..."
10: EOF, save last entry */
int digit;
+ int found_in_catalog = 0;
if (location == NULL || (strncasecmp(location, "http:", 5) &&
strncasecmp(location, "https:", 6))) {
if (location == NULL ||
(stat(location, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))) /* directory? */
+ {
filename = _findCUPSMessageCatalog(location);
+ if (filename)
+ found_in_catalog = 1;
+ }
else
filename = location;
} else {
@@ -943,6 +948,8 @@ load_opt_strings_catalog(const char *location, cups_array_t *options)
free(opt_name);
if (filename == tmpfile)
unlink(filename);
+ if (found_in_catalog)
+ free(filename);
}
@@ -1417,10 +1424,16 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
} else {
if ((current_res = resolutionArrayNew()) != NULL) {
if ((current_def = resolutionNew(lowdpi, lowdpi)) != NULL)
+ {
cupsArrayAdd(current_res, current_def);
+ free_resolution(current_def, NULL);
+ }
if (hidpi != lowdpi &&
(current_def = resolutionNew(hidpi, hidpi)) != NULL)
+ {
cupsArrayAdd(current_res, current_def);
+ free_resolution(current_def, NULL);
+ }
current_def = NULL;
if (cupsArrayCount(current_res) > 0 &&
joinResolutionArrays(&common_res, &current_res, &common_def,
@@ -1506,7 +1519,10 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (common_res == NULL) {
if ((common_res = resolutionArrayNew()) != NULL) {
if ((current_def = resolutionNew(300, 300)) != NULL)
+ {
cupsArrayAdd(common_res, current_def);
+ free_resolution(current_def, NULL);
+ }
current_def = NULL;
} else
goto bad_ppd;
diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
index 54ae2ac..507977c 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -2555,7 +2555,7 @@ record_printer_options(const char *printer) {
const char *key;
char buf[65536], *c;
const char *ppdname = NULL;
- ppd_file_t *ppd;
+ ppd_file_t *ppd = NULL;
ppd_option_t *ppd_opt;
cups_option_t *option;
int i;
@@ -2825,7 +2825,8 @@ on_printer_state_changed (CupsNotifier *object,
char *ptr, buf[1024];
remote_printer_t *p, *q;
http_t *http = NULL;
- ipp_t *request, *response;
+ ipp_t *request = NULL;
+ ipp_t *response = NULL;
ipp_attribute_t *attr;
const char *pname = NULL;
char *remote_cups_queue;
@@ -3107,6 +3108,10 @@ on_printer_state_changed (CupsNotifier *object,
break;
}
}
+ if (response) {
+ ippDelete(response);
+ response = NULL;
+ }
if (pstate == IPP_PRINTER_IDLE && paccept) {
q->last_printer = i;
break;
@@ -3863,7 +3868,7 @@ create_remote_printer_entry (const char *queue_name,
debug_printf("Default page size: %s\n",
default_page_size);
p->num_options = cupsAddOption("media-default",
- strdup(default_page_size),
+ default_page_size,
p->num_options, &(p->options));
} else {
attr = ippFindAttribute(response,
@@ -3874,7 +3879,7 @@ create_remote_printer_entry (const char *queue_name,
debug_printf("Default page size: %s\n",
default_page_size);
p->num_options = cupsAddOption("media-default",
- strdup(default_page_size),
+ default_page_size,
p->num_options, &(p->options));
} else
debug_printf("No default page size found!\n");
@@ -3889,7 +3894,7 @@ create_remote_printer_entry (const char *queue_name,
bottom = 1270;
snprintf(buffer, sizeof(buffer), "%d", bottom);
p->num_options = cupsAddOption("media-bottom-margin-default",
- strdup(buffer),
+ buffer,
p->num_options, &(p->options));
if ((attr = ippFindAttribute(response, "media-left-margin-supported", IPP_TAG_INTEGER)) != NULL) {
@@ -3900,7 +3905,7 @@ create_remote_printer_entry (const char *queue_name,
left = 635;
snprintf(buffer, sizeof(buffer), "%d", left);
p->num_options = cupsAddOption("media-left-margin-default",
- strdup(buffer),
+ buffer,
p->num_options, &(p->options));
if ((attr = ippFindAttribute(response, "media-right-margin-supported", IPP_TAG_INTEGER)) != NULL) {
@@ -3911,7 +3916,7 @@ create_remote_printer_entry (const char *queue_name,
right = 635;
snprintf(buffer, sizeof(buffer), "%d", right);
p->num_options = cupsAddOption("media-right-margin-default",
- strdup(buffer),
+ buffer,
p->num_options, &(p->options));
if ((attr = ippFindAttribute(response, "media-top-margin-supported", IPP_TAG_INTEGER)) != NULL) {
@@ -3922,7 +3927,7 @@ create_remote_printer_entry (const char *queue_name,
top = 1270;
snprintf(buffer, sizeof(buffer), "%d", top);
p->num_options = cupsAddOption("media-top-margin-default",
- strdup(buffer),
+ buffer,
p->num_options, &(p->options));
debug_printf("Margins: Left: %d, Right: %d, Top: %d, Bottom: %d\n",
@@ -3943,7 +3948,7 @@ create_remote_printer_entry (const char *queue_name,
debug_printf("Best color space: %s\n",
best_color_space);
p->num_options = cupsAddOption("print-color-mode-default",
- strdup(best_color_space),
+ best_color_space,
p->num_options, &(p->options));
} else {
debug_printf("No info about supported color spaces found!\n");
@@ -3956,7 +3961,7 @@ create_remote_printer_entry (const char *queue_name,
p->num_options = cupsAddOption("sides-default", "two-sided-long-edge",
p->num_options, &(p->options));
- p->num_options = cupsAddOption("output-format-default", strdup(pdl),
+ p->num_options = cupsAddOption("output-format-default", pdl,
p->num_options, &(p->options));
p->num_options = cupsAddOption("make-and-model-default",
remove_bad_chars(make_model, 0),
@@ -4119,7 +4124,7 @@ gboolean update_cups_queues(gpointer unused) {
char *disabled_str, *ptr, *prefix;
const char *loadedppd = NULL;
int pass_through_ppd;
- ppd_file_t *ppd;
+ ppd_file_t *ppd = NULL;
ppd_choice_t *choice;
cups_file_t *in, *out;
char keyword[1024], *keyptr;
@@ -4588,6 +4593,7 @@ gboolean update_cups_queues(gpointer unused) {
p->timeout = current_time + TIMEOUT_RETRY;
p->no_autosave = 0;
ppdClose(ppd);
+ ppd = NULL;
unlink(loadedppd);
break;
}
@@ -4597,6 +4603,7 @@ gboolean update_cups_queues(gpointer unused) {
p->no_autosave = 0;
cupsFileClose(out);
ppdClose(ppd);
+ ppd = NULL;
unlink(loadedppd);
break;
}
@@ -4710,6 +4717,7 @@ gboolean update_cups_queues(gpointer unused) {
cupsFileClose(in);
cupsFileClose(out);
ppdClose(ppd);
+ ppd = NULL;
unlink(loadedppd);
loadedppd = NULL;
if (p->ppd)
@@ -4748,8 +4756,8 @@ gboolean update_cups_queues(gpointer unused) {
/* Default option settings from printer entry */
for (i = 0; i < p->num_options; i ++)
if (strcasecmp(p->options[i].name, "printer-is-shared"))
- num_options = cupsAddOption(strdup(p->options[i].name),
- strdup(p->options[i].value),
+ num_options = cupsAddOption(p->options[i].name,
+ p->options[i].value,
num_options, &options);
/* Encode option list into IPP attributes */
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
@@ -8342,6 +8350,9 @@ fail:
if (local_printers_context) {
browse_poll_cancel_subscription (local_printers_context);
+#ifdef HAVE_CUPS_2_0
+ free(local_printers_context->server);
+#endif
g_list_free_full (local_printers_context->printers,
browsepoll_printer_free);
free (local_printers_context);

View File

@ -4,7 +4,7 @@
Summary: OpenPrinting CUPS filters and backends
Name: cups-filters
Version: 1.20.0
Release: 19%{?dist}
Release: 20%{?dist}
# For a breakdown of the licensing, see COPYING file
# GPLv2: filters: commandto*, imagetoraster, pdftops, rasterto*,
@ -39,6 +39,10 @@ Patch06: 0001-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch
Patch07: pdftopdf-nocrypt.patch
# 1776270 - cups-browsed leaks sockets
Patch08: cups-browsed-socket-leak.patch
# 1677731 - error messages when using cups-browsed
Patch09: cups-browsed-error-messages.patch
# 1813229 - cups-browsed leaks memory
Patch10: cups-browsed-memory-leaks.patch
Requires: cups-filters-libs%{?_isa} = %{version}-%{release}
@ -108,6 +112,11 @@ Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
# recommends avahi and cups-ipptool - it is needed for driverless support,
# but it is useless for older devices and cups servers
Recommends: avahi
Recommends: cups-ipptool
# older installations can still have ghostscript-cups and foomatic-filters
# installed, but they are replaced by cups-filters now. We need to obsolete
# them to have them uninstalled (#1632268)
@ -156,6 +165,10 @@ This is the development package for OpenPrinting CUPS filters and backends.
%patch07 -p1 -b .pdftopdf-nocrypt
# 1776270 - cups-browsed leaks sockets
%patch08 -p1 -b .cups-browsed-socket-leak
# 1677731 - error messages when using cups-browsed
%patch09 -p1 -b .cups-browsed-error-messages
# 1813229 - cups-browsed leaks memory
%patch10 -p1 -b .cups-browsed-memory-leak
%build
# work-around Rpath
@ -302,6 +315,13 @@ make check
%{_libdir}/libfontembed.so
%changelog
* Wed Apr 08 2020 Zdenek Dohnal <zdohnal@redhat.com> - 1.20.0-20
- 1813229 - cups-browsed leaks memory
* Mon Apr 06 2020 Zdenek Dohnal <zdohnal@redhat.com> - 1.20.0-20
- 1677731 - error messages when using cups-browsed
- 1776230 - missing dependency for ippfind
* Mon Nov 25 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.20.0-19
- 1776270 - cups-browsed leaks sockets