From 775c3bb584b2b5f0e421e68025f3fec6d797c683 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Wed, 16 Oct 2019 15:52:01 +0200 Subject: [PATCH] 1750904 - cups is unable to add ppd with custom/Custom option --- ...ning-custom-option-keywords-did-not-.patch | 49 +++++++++++++++++++ ...in-CUPS-web-ui-when-adding-a-printer.patch | 7 --- cups.spec | 7 +++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 0001-PPD-files-containing-custom-option-keywords-did-not-.patch diff --git a/0001-PPD-files-containing-custom-option-keywords-did-not-.patch b/0001-PPD-files-containing-custom-option-keywords-did-not-.patch new file mode 100644 index 0000000..32b9d0a --- /dev/null +++ b/0001-PPD-files-containing-custom-option-keywords-did-not-.patch @@ -0,0 +1,49 @@ +From 2a06655e5c1925f09d5a2e38cd073eb1b6f069ad Mon Sep 17 00:00:00 2001 +From: Michael R Sweet +Date: Tue, 15 Oct 2019 17:05:55 -0400 +Subject: [PATCH] PPD files containing custom option keywords did not work + (Issue #5639) + +diff --git a/cups/ppd.c b/cups/ppd.c +index fae19c42e..ff52df2e1 100644 +--- a/cups/ppd.c ++++ b/cups/ppd.c +@@ -1874,9 +1874,9 @@ _ppdOpen( + { + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { +- pg->ppd_status = PPD_ILLEGAL_OPTION_KEYWORD; +- +- goto error; ++ char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ ++ snprintf(cname, sizeof(cname), "_%s", name); ++ strlcpy(name, cname, sizeof(name)); + } + + if ((size = ppdPageSize(ppd, name)) == NULL) +@@ -1903,9 +1903,9 @@ _ppdOpen( + { + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { +- pg->ppd_status = PPD_ILLEGAL_OPTION_KEYWORD; +- +- goto error; ++ char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ ++ snprintf(cname, sizeof(cname), "_%s", name); ++ strlcpy(name, cname, sizeof(name)); + } + + if ((size = ppdPageSize(ppd, name)) == NULL) +@@ -1939,9 +1939,9 @@ _ppdOpen( + + if (!_cups_strcasecmp(name, "custom") || !_cups_strncasecmp(name, "custom.", 7)) + { +- pg->ppd_status = PPD_ILLEGAL_OPTION_KEYWORD; +- +- goto error; ++ char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */ ++ snprintf(cname, sizeof(cname), "_%s", name); ++ strlcpy(name, cname, sizeof(name)); + } + + if (!strcmp(keyword, "PageSize")) diff --git a/0001-SIGSEGV-in-CUPS-web-ui-when-adding-a-printer.patch b/0001-SIGSEGV-in-CUPS-web-ui-when-adding-a-printer.patch index 068a894..0428793 100644 --- a/0001-SIGSEGV-in-CUPS-web-ui-when-adding-a-printer.patch +++ b/0001-SIGSEGV-in-CUPS-web-ui-when-adding-a-printer.patch @@ -3,10 +3,6 @@ From: Zdenek Dohnal Date: Mon, 29 Jul 2019 10:33:06 +0200 Subject: [PATCH] SIGSEGV in CUPS web ui when adding a printer ---- - cgi-bin/var.c | 3 +++ - 1 file changed, 3 insertions(+) - diff --git a/cgi-bin/var.c b/cgi-bin/var.c index 306375bd6..fb9d051c0 100644 --- a/cgi-bin/var.c @@ -21,6 +17,3 @@ index 306375bd6..fb9d051c0 100644 return (strdup(var->values[element])); } --- -2.21.0 - diff --git a/cups.spec b/cups.spec index 3901b94..cd6aa2b 100644 --- a/cups.spec +++ b/cups.spec @@ -100,6 +100,10 @@ Patch29: cups-dymo-deviceid.patch Patch40: 0001-Add-workaround-for-systemd-s-lack-of-true-launch-on-.patch # SIGSEGV in web ui Patch41: 0001-SIGSEGV-in-CUPS-web-ui-when-adding-a-printer.patch +# some ppds use custom keyword, which is incorrect - the correct is 'Custom Size' and ppd +# parser ended with error when encountered it. Now the parser adds underscore to incorrect +# keyword and continues +Patch42: 0001-PPD-files-containing-custom-option-keywords-did-not-.patch ##### Patches removed because IMHO they aren't no longer needed ##### but still I'll leave them in git in case their removal @@ -347,6 +351,8 @@ Sends IPP requests to the specified URI and tests and/or displays the results. %patch40 -p1 -b .cupsctl-not-working # 1720688 - [abrt] cups: __strlen_avx2(): printers.cgi killed by SIGSEGV %patch41 -p1 -b .webui-sigsegv +# 1750904 - cups is unable to add ppd with custom/Custom option +%patch42 -p1 -b .ppd-custom-option # if cupsd is set to log into /var/log/cups, then 'MaxLogSize 0' needs to be # in cupsd.conf to disable cupsd logrotate functionality and use logrotated @@ -755,6 +761,7 @@ rm -f %{cups_serverbin}/backend/smb %changelog * Wed Oct 16 2019 Zdenek Dohnal - 1:2.2.12-3 - 1720688 - [abrt] cups: __strlen_avx2(): printers.cgi killed by SIGSEGV +- 1750904 - cups is unable to add ppd with custom/Custom option * Fri Sep 13 2019 Zdenek Dohnal - 1:2.2.12-2 - fix cupsctl usage