summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2019-11-22 14:55:41 +0100
committerDidier Raboud <odyx@debian.org>2019-11-22 14:55:41 +0100
commiteac8a40259703913a677501c47e39c53ff76cc1b (patch)
tree7dafda46e9acbf83556ebf4da0f19827c958bfd7
parent6499cd24a204d1c72a2a1fa65a711273d9b025cc (diff)
New upstream version 1.25.12
-rw-r--r--INSTALL2
-rw-r--r--NEWS36
-rw-r--r--README2
-rw-r--r--backend/beh.c2
-rw-r--r--backend/implicitclass.c10
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac2
-rw-r--r--cupsfilters/colormanager.c2
-rw-r--r--cupsfilters/pdftoippprinter.c2
-rw-r--r--cupsfilters/ppdgenerator.c44
-rw-r--r--cupsfilters/raster.c39
-rw-r--r--filter/foomatic-rip/foomaticrip.c9
-rw-r--r--filter/imagetopdf.c2
-rw-r--r--filter/mupdftoraster.c2
-rw-r--r--filter/pdftops.c26
-rw-r--r--filter/sys5ippprinter.c2
-rw-r--r--utils/cups-browsed.c65
-rw-r--r--utils/driverless.c16
18 files changed, 176 insertions, 107 deletions
diff --git a/INSTALL b/INSTALL
index 9a3e9c04b..2a0d25e92 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-INSTALL - OpenPrinting CUPS Filters v1.25.11 - 2019-10-10
+INSTALL - OpenPrinting CUPS Filters v1.25.12 - 2019-11-12
---------------------------------------------------------
This file describes how to compile and install OpenPrinting CUPS
diff --git a/NEWS b/NEWS
index 420cfaba4..67d1c18f2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,43 @@
-NEWS - OpenPrinting CUPS Filters v1.25.11 - 2019-10-10
+NEWS - OpenPrinting CUPS Filters v1.25.12 - 2019-11-12
------------------------------------------------------
+CHANGES IN V1.25.12
+
+ - libcupsfilters: Use the text names "Draft", "Normal", and
+ "High" instead of 3, 4, and 5 as choice names for the
+ "cupsPrintQuality" option as CUPS does (Issue #171).
+ - libcupsfilters: If a printer supports both Apple Raster and
+ PWG Raster let the generated PPD use Apple Raster as there
+ are several printers which report PWG Raster support but do
+ not actually print PWG Raster (Pull reguest #168, Issue
+ #171, CUPS issue #5238).
+ - cups-browsed: Fix unset location check to use DNS-SD field
+ (Pull request #172).
+ - libcupsfilters, beh, implicitclass, foomatic-rip,
+ imagetopdf, mupdftoraster, pdftops, sys5ippprinter,
+ cups-browsed, driverless: Silenced all compiler warnings to
+ make the build process of cups-filters completely free of
+ warnings.
+ - pdftops: Fixed crash when using filter without PPD file.
+ - pdftops: If printing grayscale jobs with Ghostscript as PDF
+ renderer, add "-sProcessColorModel=DeviceGray" to
+ Ghostscript command line.
+ - pdftops: Do not use the ugly "pdftops -level1 ..."
+ workaround to get grayscale PostScript output from
+ Poppler. It leads to huge output files with Poppler's
+ "pdftops" utility and does not work at all with
+ "pdftocairo". Poppler itself does not support PostScript
+ output converted to grayscale. Issue a warning with the hint
+ to use Ghostscript or MuPDF as PDF renderer (Issue #169).
+ - libcupsfilters: In the cupsRasterParseIPPOptions()
+ accept also "Mono", "Monochrome", and "Gray" as color
+ space names.
+
CHANGES IN V1.25.11
- cups-browsed: Really accept entries without printer name
reported on a job status request (Issue #163).
- - cups-browsed: Strip IPP atrribute values reported by the
+ - cups-browsed: Strip IPP attribute values reported by the
printer on a get-printer-attributes request from white
space (Pull request #166).
diff --git a/README b/README
index 7a974f831..98dc9f633 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README - OpenPrinting CUPS Filters v1.25.11 - 2019-10-10
+README - OpenPrinting CUPS Filters v1.25.12 - 2019-11-12
--------------------------------------------------------
Looking for compile instructions? Read the file "INSTALL.txt"
diff --git a/backend/beh.c b/backend/beh.c
index 7514e3376..225fd27d5 100644
--- a/backend/beh.c
+++ b/backend/beh.c
@@ -222,7 +222,7 @@ call_backend(char *uri, /* I - URI of final destination */
* Build the backend command line...
*/
- strncpy(scheme, uri, sizeof(scheme));
+ strncpy(scheme, uri, sizeof(scheme) - 1);
if (strlen(uri) > 1023)
scheme[1023] = '\0';
if ((ptr = strchr(scheme, ':')) != NULL)
diff --git a/backend/implicitclass.c b/backend/implicitclass.c
index cd4b11d11..a4b0dbf08 100644
--- a/backend/implicitclass.c
+++ b/backend/implicitclass.c
@@ -189,7 +189,7 @@ main(int argc, /* I - Number of command-line args */
break;
}
fprintf(stderr, "DEBUG: Read " CUPS_BROWSED_DEST_PRINTER " option: %s\n",
- ptr1);
+ (ptr1 ? ptr1 : "Option not found"));
if (ptr1 == NULL)
goto failed;
/* Destination host is between double quotes, as double quotes are
@@ -222,7 +222,7 @@ main(int argc, /* I - Number of command-line args */
queue_name);
return (CUPS_BACKEND_STOP);
}
- strncpy(dest_host,ptr1,sizeof(dest_host));
+ strncpy(dest_host,ptr1,sizeof(dest_host) - 1);
if (!strcmp(dest_host, "NO_DEST_FOUND")) {
/* All remote queues are either disabled or not accepting jobs, let
CUPS retry after the usual interval */
@@ -279,9 +279,9 @@ main(int argc, /* I - Number of command-line args */
ptr4++;
}
- strncpy(printer_uri, ptr1, sizeof(printer_uri));
- strncpy(document_format, ptr3, sizeof(document_format));
- strncpy(resolution, ptr4, sizeof(resolution));
+ strncpy(printer_uri, ptr1, sizeof(printer_uri) - 1);
+ strncpy(document_format, ptr3, sizeof(document_format) - 1);
+ strncpy(resolution, ptr4, sizeof(resolution) - 1);
fprintf(stderr,"DEBUG: Received job for the printer with the destination uri - %s, Final-document format for the printer - %s and requested resolution - %s\n",
printer_uri, document_format, resolution);
diff --git a/configure b/configure
index f51bcb648..4e494e765 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for cups-filters 1.25.11.
+# Generated by GNU Autoconf 2.69 for cups-filters 1.25.12.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cups-filters'
PACKAGE_TARNAME='cups-filters'
-PACKAGE_VERSION='1.25.11'
-PACKAGE_STRING='cups-filters 1.25.11'
+PACKAGE_VERSION='1.25.12'
+PACKAGE_STRING='cups-filters 1.25.12'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1513,7 +1513,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures cups-filters 1.25.11 to adapt to many kinds of systems.
+\`configure' configures cups-filters 1.25.12 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1584,7 +1584,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of cups-filters 1.25.11:";;
+ short | recursive ) echo "Configuration of cups-filters 1.25.12:";;
esac
cat <<\_ACEOF
@@ -1817,7 +1817,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-cups-filters configure 1.25.11
+cups-filters configure 1.25.12
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2497,7 +2497,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by cups-filters $as_me 1.25.11, which was
+It was created by cups-filters $as_me 1.25.12, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3533,7 +3533,7 @@ fi
# Define the identity of the package.
PACKAGE='cups-filters'
- VERSION='1.25.11'
+ VERSION='1.25.12'
cat >>confdefs.h <<_ACEOF
@@ -24277,7 +24277,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by cups-filters $as_me 1.25.11, which was
+This file was extended by cups-filters $as_me 1.25.12, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -24343,7 +24343,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-cups-filters config.status 1.25.11
+cups-filters config.status 1.25.12
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index e0dcbc3df..22e9a40ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AC_PREREQ([2.65])
# ====================
m4_define([cups_filters_version_major],[1])
m4_define([cups_filters_version_minor],[25])
-m4_define([cups_filters_version_micro],[11])
+m4_define([cups_filters_version_micro],[12])
m4_define([cups_filters_version],[cups_filters_version_major.cups_filters_version_minor.cups_filters_version_micro])
# =============
diff --git a/cupsfilters/colormanager.c b/cupsfilters/colormanager.c
index a4a929d15..b443718ff 100644
--- a/cupsfilters/colormanager.c
+++ b/cupsfilters/colormanager.c
@@ -329,7 +329,7 @@ _get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier)
snprintf(full_path, sizeof(full_path),
"%s/profiles/%s", CUPSDATA, attr->value);
else {
- strncpy(full_path, attr->value, sizeof(full_path));
+ strncpy(full_path, attr->value, sizeof(full_path) - 1);
if (strlen(attr->value) > 1023)
full_path[1023] = '\0';
}
diff --git a/cupsfilters/pdftoippprinter.c b/cupsfilters/pdftoippprinter.c
index 9d069b4d9..ea5427b8c 100644
--- a/cupsfilters/pdftoippprinter.c
+++ b/cupsfilters/pdftoippprinter.c
@@ -724,7 +724,7 @@ exec_filters(cups_array_t *filters, /* I - Array of filters to run */
next = (char *)cupsArrayNext(filters);
if (filter[0] == '/') {
- strncpy(program, filter, sizeof(program));
+ strncpy(program, filter, sizeof(program) - 1);
if (strlen(filter) > 1023)
program[1023] = '\0';
} else {
diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c
index bf207d5da..bd2c78068 100644
--- a/cupsfilters/ppdgenerator.c
+++ b/cupsfilters/ppdgenerator.c
@@ -1868,21 +1868,6 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */
formatfound = 1;
is_pdf = 1;
}
- if (cupsArrayFind(pdl_list, "image/pwg-raster")) {
- if ((attr = ippFindAttribute(response,
- "pwg-raster-document-resolution-supported",
- IPP_TAG_RESOLUTION)) != NULL) {
- current_def = NULL;
- if ((current_res = ippResolutionListToArray(attr)) != NULL &&
- joinResolutionArrays(&common_res, &current_res, &common_def,
- &current_def)) {
- cupsFilePuts(fp, "*cupsFilter2: \"image/pwg-raster image/pwg-raster 0 -\"\n");
- if (formatfound == 0) manual_copies = 1;
- formatfound = 1;
- is_pwg = 1;
- }
- }
- }
#ifdef CUPS_RASTER_HAVE_APPLERASTER
if (cupsArrayFind(pdl_list, "image/urf")) {
if ((attr = ippFindAttribute(response, "urf-supported",
@@ -1923,6 +1908,21 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */
}
}
#endif
+ if (is_apple == 0 && cupsArrayFind(pdl_list, "image/pwg-raster")) {
+ if ((attr = ippFindAttribute(response,
+ "pwg-raster-document-resolution-supported",
+ IPP_TAG_RESOLUTION)) != NULL) {
+ current_def = NULL;
+ if ((current_res = ippResolutionListToArray(attr)) != NULL &&
+ joinResolutionArrays(&common_res, &current_res, &common_def,
+ &current_def)) {
+ cupsFilePuts(fp, "*cupsFilter2: \"image/pwg-raster image/pwg-raster 0 -\"\n");
+ if (formatfound == 0) manual_copies = 1;
+ formatfound = 1;
+ is_pwg = 1;
+ }
+ }
+ }
#ifdef QPDF_HAVE_PCLM
if (cupsArrayFind(pdl_list, "application/PCLm")) {
if ((attr = ippFindAttribute(response, "pclm-source-resolution-supported",
@@ -3461,31 +3461,27 @@ ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *cupsPrintQuality/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
- "*DefaultcupsPrintQuality: %d\n",
+ "*DefaultcupsPrintQuality: Normal\n",
(human_readable ? human_readable :
- _cupsLangString(lang, _("Print Quality"))),
- IPP_QUALITY_NORMAL);
+ _cupsLangString(lang, _("Print Quality"))));
if (ippContainsInteger(quality, IPP_QUALITY_DRAFT)) {
human_readable = lookup_choice("3", "print-quality", opt_strings_catalog,
printer_opt_strings_catalog);
- cupsFilePrintf(fp, "*cupsPrintQuality %d/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
- IPP_QUALITY_DRAFT,
+ cupsFilePrintf(fp, "*cupsPrintQuality Draft/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
(human_readable ? human_readable :
_cupsLangString(lang, _("Draft"))),
min_res->x, min_res->y);
}
human_readable = lookup_choice("4", "print-quality", opt_strings_catalog,
printer_opt_strings_catalog);
- cupsFilePrintf(fp, "*cupsPrintQuality %d/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
- IPP_QUALITY_NORMAL,
+ cupsFilePrintf(fp, "*cupsPrintQuality Normal/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
(human_readable ? human_readable :
_cupsLangString(lang, _("Normal"))),
common_def->x, common_def->y);
if (ippContainsInteger(quality, IPP_QUALITY_HIGH)) {
human_readable = lookup_choice("5", "print-quality", opt_strings_catalog,
printer_opt_strings_catalog);
- cupsFilePrintf(fp, "*cupsPrintQuality %d/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
- IPP_QUALITY_HIGH,
+ cupsFilePrintf(fp, "*cupsPrintQuality High/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n",
(human_readable ? human_readable :
_cupsLangString(lang, _("High"))),
max_res->x, max_res->y);
diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c
index 73fa868e8..c8e2b8f9e 100644
--- a/cupsfilters/raster.c
+++ b/cupsfilters/raster.c
@@ -766,29 +766,45 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */
bitspercolor = 8;
if (!strncasecmp(val, "AdobeRgb", 8))
{
- if (*(val + 8) == '_' || *(val + 8) == '-')
+ if (*(val + 8) == '_' || *(val + 8) == '-')
ptr = val + 9;
colorspace = 20;
numcolors = 3;
}
else if (!strncasecmp(val, "Black", 5))
{
- if (*(val + 5) == '_' || *(val + 5) == '-')
+ if (*(val + 5) == '_' || *(val + 5) == '-')
ptr = val + 6;
bitspercolor = 1;
colorspace = 3;
numcolors = 1;
}
+ else if (!strncasecmp(val, "Monochrome", 10))
+ {
+ if (*(val + 10) == '_' || *(val + 10) == '-')
+ ptr = val + 11;
+ bitspercolor = 1;
+ colorspace = 3;
+ numcolors = 1;
+ }
+ else if (!strncasecmp(val, "Mono", 4))
+ {
+ if (*(val + 4) == '_' || *(val + 4) == '-')
+ ptr = val + 5;
+ bitspercolor = 1;
+ colorspace = 3;
+ numcolors = 1;
+ }
else if (!strncasecmp(val, "Cmyk", 4))
{
- if (*(val + 4) == '_' || *(val + 4) == '-')
+ if (*(val + 4) == '_' || *(val + 4) == '-')
ptr = val + 5;
colorspace = 6;
numcolors = 4;
}
else if (!strncasecmp(val, "Cmy", 3))
{
- if (*(val + 3) == '_' || *(val + 3) == '-')
+ if (*(val + 3) == '_' || *(val + 3) == '-')
ptr = val + 4;
colorspace = 4;
numcolors = 3;
@@ -810,28 +826,35 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */
}
else if (!strncasecmp(val, "Sgray", 5))
{
- if (*(val + 5) == '_' || *(val + 5) == '-')
+ if (*(val + 5) == '_' || *(val + 5) == '-')
ptr = val + 6;
colorspace = 18;
numcolors = 1;
}
+ else if (!strncasecmp(val, "Gray", 4))
+ {
+ if (*(val + 4) == '_' || *(val + 4) == '-')
+ ptr = val + 5;
+ colorspace = 3;
+ numcolors = 1;
+ }
else if (!strncasecmp(val, "Srgb", 4))
{
- if (*(val + 4) == '_' || *(val + 4) == '-')
+ if (*(val + 4) == '_' || *(val + 4) == '-')
ptr = val + 5;
colorspace = 19;
numcolors = 3;
}
else if (!strncasecmp(val, "Rgbw", 4))
{
- if (*(val + 4) == '_' || *(val + 4) == '-')
+ if (*(val + 4) == '_' || *(val + 4) == '-')
ptr = val + 5;
colorspace = 17;
numcolors = 4;
}
else if (!strncasecmp(val, "Rgb", 3))
{
- if (*(val + 3) == '_' || *(val + 3) == '-')
+ if (*(val + 3) == '_' || *(val + 3) == '-')
ptr = val + 4;
colorspace = 1;
numcolors = 3;
diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c
index ed4ae1d00..3b27ce939 100644
--- a/filter/foomatic-rip/foomaticrip.c
+++ b/filter/foomatic-rip/foomaticrip.c
@@ -818,12 +818,13 @@ int main(int argc, char** argv)
}
if (getenv("PPD")) {
- strncpy(job->ppdfile, getenv("PPD"), 2048);
+ strncpy(job->ppdfile, getenv("PPD"), sizeof(job->ppdfile) - 1);
if (strlen(getenv("PPD")) > 2047)
job->ppdfile[2047] = '\0';
spooler = SPOOLER_CUPS;
if (getenv("CUPS_SERVERBIN")) {
- strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"), sizeof(cupsfilterpath));
+ strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"),
+ sizeof(cupsfilterpath) - 1);
if (strlen(getenv("CUPS_SERVERBIN")) > PATH_MAX-1)
cupsfilterpath[PATH_MAX-1] = '\0';
}
@@ -845,13 +846,13 @@ int main(int argc, char** argv)
/* PPD file name given via the command line
allow duplicates, and use the last specified one */
while ((str = arglist_get_value(arglist, "-p"))) {
- strncpy(job->ppdfile, str, 2048);
+ strncpy(job->ppdfile, str, sizeof(job->ppdfile) - 1);
if (strlen(str) > 2047)
job->ppdfile[2047] = '\0';
arglist_remove(arglist, "-p");
}
while ((str = arglist_get_value(arglist, "--ppd"))) {
- strncpy(job->ppdfile, str, 2048);
+ strncpy(job->ppdfile, str, sizeof(job->ppdfile) - 1);
if (strlen(str) > 2047)
job->ppdfile[2047] = '\0';
arglist_remove(arglist, "--ppd");
diff --git a/filter/imagetopdf.c b/filter/imagetopdf.c
index 3c7bb6659..cc72cea02 100644
--- a/filter/imagetopdf.c
+++ b/filter/imagetopdf.c
@@ -745,7 +745,7 @@ main(int argc, /* I - Number of command-line arguments */
}
else
{
- strncpy(filename, argv[6], sizeof(filename));
+ strncpy(filename, argv[6], sizeof(filename) - 1);
}
/*
diff --git a/filter/mupdftoraster.c b/filter/mupdftoraster.c
index 8ba7a5743..75e2f7656 100644
--- a/filter/mupdftoraster.c
+++ b/filter/mupdftoraster.c
@@ -312,7 +312,7 @@ main (int argc, char **argv, char *envp[])
fprintf(stderr, "ERROR: Can't open input file %s\n",argv[6]);
goto out;
}
- strncpy(infilename, argv[6], 1024);
+ strncpy(infilename, argv[6], sizeof(infilename) - 1);
}
/* If doc type is not PDF exit */
diff --git a/filter/pdftops.c b/filter/pdftops.c
index f50ba63da..2ff74c6c4 100644
--- a/filter/pdftops.c
+++ b/filter/pdftops.c
@@ -406,7 +406,7 @@ main(int argc, /* I - Number of command-line args */
if ((val = cupsGetOption("make-and-model", num_options, options)) != NULL)
{
- strncpy(make_model, val, sizeof(make_model));
+ strncpy(make_model, val, sizeof(make_model) - 1);
if (strlen(val) > 127)
make_model[127] = '\0';
for (ptr = make_model; *ptr; ptr ++)
@@ -542,7 +542,7 @@ main(int argc, /* I - Number of command-line args */
* Force monochrome/grayscale PostScript output
* if job is to be printed in monochrome/grayscale
*/
- if (ppd->color_device == 0) /* Monochrome printer */
+ if (ppd && ppd->color_device == 0) /* Monochrome printer */
gray_output = 1;
else /*Color Printer - user option for Grayscale */
{
@@ -602,8 +602,9 @@ main(int argc, /* I - Number of command-line args */
if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
output */
{
- pdf_argv[9] = (char *)"-sColorConversionStrategy=Gray";
- pdf_argc = 10;
+ pdf_argv[9] = (char *)"-sProcessColorModel=DeviceGray";
+ pdf_argv[10] = (char *)"-sColorConversionStrategy=Gray";
+ pdf_argc = 11;
}
else
pdf_argc = 9;
@@ -861,8 +862,21 @@ main(int argc, /* I - Number of command-line args */
#endif /* HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION */
if (gray_output == 1) /* Checking for monochrome/grayscale PostScript output */
{
- pdf_argv[1] = (char *)"-level1";
- pdf_argv[pdf_argc++] = (char *)"-optimizecolorspace";
+ /* Poppler does not explicitly support turning colored PDF files into
+ grayscale PostScript. As a workaround, one could let the "pdftops"
+ command line utility generate PostScript level 1 output which is
+ always grayscale, but output files get huge and printing too
+ slow.
+ Recommended solution is to not use Poppler as PDF renderer for
+ printing, especially if one uses a color PostScript printer and
+ wants to have the possibility to print jobs also in grayscale.
+ See the use of the "pdftops-renderer" option in the README file. */
+ /* Example code for PostScript level1 workaround: */
+ /* pdf_argv[1] = (char *)"-level1";
+ pdf_argv[pdf_argc++] = (char *)"-optimizecolorspace"; */
+ /* Issue a warning message when printing a grayscale job with Poppler */
+ fprintf(stderr, "WARNING: Grayscale/monochrome printing requested for this job but Poppler is not able to convert to grayscale/monochrome PostScript.\n");
+ fprintf(stderr, "WARNING: Use \"pdftops-renderer\" option (see README file) to use Ghostscript or MuPDF for the PDF -> PostScript conversion.\n");
}
pdf_argv[pdf_argc++] = filename;
pdf_argv[pdf_argc++] = (char *)"-";
diff --git a/filter/sys5ippprinter.c b/filter/sys5ippprinter.c
index 9a92c8e8e..6608e4749 100644
--- a/filter/sys5ippprinter.c
+++ b/filter/sys5ippprinter.c
@@ -661,7 +661,7 @@ exec_filters(cups_array_t *filters, /* I - Array of filters to run */
next = (char *)cupsArrayNext(filters);
if (filter[0] == '/') {
- strncpy(program, filter, sizeof(program));
+ strncpy(program, filter, sizeof(program) - 1);
if (strlen(filter) > 1023)
program[1023] = '\0';
}
diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
index 59cf2c262..adbf5002f 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -469,10 +469,10 @@ static FILE *lfp = NULL;
static char cachedir[1024];
static char logdir[1024];
-static char local_default_printer_file[1024];
-static char remote_default_printer_file[1024];
-static char save_options_file[1024];
-static char debug_log_file[1024];
+static char local_default_printer_file[2048];
+static char remote_default_printer_file[2048];
+static char save_options_file[2048];
+static char debug_log_file[2048];
/*Contains ppd keywords which are written by ppdgenerator.c in the ppd file.*/
static char* ppd_keywords[] =
@@ -1306,7 +1306,7 @@ void add_mimetype_attributes(char* cluster_name, ipp_t **merged_attributes)
q;
q = (char *)cupsArrayNext(list),i++) {
values[i]=malloc(sizeof(char)*strlen(q)+1);
- strncpy(values[i],q,strlen(q)+1);
+ strncpy(values[i], q, sizeof(values[i]) - 1);
}
ippAddStrings(*merged_attributes, IPP_TAG_PRINTER,IPP_TAG_MIMETYPE,
attributes[attr_no], num_value, NULL,
@@ -1370,7 +1370,7 @@ void add_tagzero_attributes(char* cluster_name,ipp_t **merged_attributes)
for (q = (char *)cupsArrayFirst(list), i = 0; q;
q = (char *)cupsArrayNext(list), i++) {
values[i]=malloc(sizeof(char)*strlen(q)+1);
- strncpy(values[i],q,strlen(q)+1);
+ strncpy(values[i], q, sizeof(values[i]) - 1);
}
ippAddStrings(*merged_attributes, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
attributes[attr_no], num_value, NULL,
@@ -1432,7 +1432,7 @@ void add_keyword_attributes(char* cluster_name,ipp_t **merged_attributes)
q;
q = (char *)cupsArrayNext(list), i++) {
values[i]=malloc(sizeof(char)*strlen(q)+1);
- strncpy(values[i],q,strlen(q)+1);
+ strncpy(values[i], q, sizeof(values[i]) - 1);
}
ippAddStrings(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
attributes[attr_no], num_value, NULL,
@@ -4322,7 +4322,7 @@ cupsdUpdateLDAPBrowse(void)
host[HTTP_MAX_URI], /* Hostname */
resource[HTTP_MAX_URI], /* Resource path */
local_resource[HTTP_MAX_URI], /* Resource path */
- service_name[2048],
+ service_name[4096],
location[1024], /* Printer location */
info[1024], /* Printer information */
make_model[1024], /* Printer make and model */
@@ -6095,11 +6095,11 @@ on_job_state (CupsNotifier *object,
valid_dest_found = 1;
dest_host = p->ip ? p->ip : p->host;
dest_port = p->port;
- strncpy(destination_uri,p->uri,sizeof(destination_uri));
+ strncpy(destination_uri, p->uri, sizeof(destination_uri) - 1);
printer_attributes = p->prattrs;
pdl = p->pdl;
s = p;
- strncpy(dest_name, remote_cups_queue, sizeof(dest_name));
+ strncpy(dest_name, remote_cups_queue, sizeof(dest_name) - 1);
if (strlen(remote_cups_queue) > 1023)
dest_name[1023] = '\0';
dest_index = i;
@@ -6116,12 +6116,12 @@ on_job_state (CupsNotifier *object,
min_jobs = num_jobs;
dest_host = p->ip ? p->ip : p->host;
dest_port = p->port;
- strncpy(destination_uri,p->uri,sizeof(destination_uri));
+ strncpy(destination_uri, p->uri, sizeof(destination_uri) - 1);
printer_attributes = p->prattrs;
pdl = p->pdl;
s = p;
strncpy(dest_name, remote_cups_queue,
- sizeof(dest_name));
+ sizeof(dest_name) - 1);
if (strlen(remote_cups_queue) > 1023)
dest_name[1023] = '\0';
dest_index = i;
@@ -7047,7 +7047,7 @@ create_remote_printer_entry (const char *queue_name,
debug_printf(" Attr: %s\n", ippGetName(attr));
for (i = 0; i < ippGetCount(attr); i ++) {
strncpy(valuebuffer, ippGetString(attr, i, NULL),
- sizeof(valuebuffer));
+ sizeof(valuebuffer) - 1);
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -7081,7 +7081,7 @@ create_remote_printer_entry (const char *queue_name,
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
strncpy(valuebuffer, ippGetString(attr, i, NULL),
- sizeof(valuebuffer));
+ sizeof(valuebuffer) - 1);
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -7114,7 +7114,7 @@ create_remote_printer_entry (const char *queue_name,
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
strncpy(valuebuffer, ippGetString(attr, i, NULL),
- sizeof(valuebuffer));
+ sizeof(valuebuffer) - 1);
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -7150,7 +7150,7 @@ create_remote_printer_entry (const char *queue_name,
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
strncpy(valuebuffer, ippGetString(attr, i, NULL),
- sizeof(valuebuffer));
+ sizeof(valuebuffer) - 1);
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -7844,7 +7844,8 @@ gboolean update_cups_queues(gpointer unused) {
if ((attr = ippFindAttribute(printer_attributes,
"printer-make-and-model",
IPP_TAG_TEXT)) != NULL)
- strncpy(make_model, ippGetString(attr, 0, NULL), 256);
+ strncpy(make_model, ippGetString(attr, 0, NULL),
+ sizeof(make_model) - 1);
color = 0;
duplex = 0;
for (r = (remote_printer_t *)cupsArrayFirst(remote_printers);
@@ -8159,7 +8160,8 @@ gboolean update_cups_queues(gpointer unused) {
if((attr = ippFindAttribute(printer_attributes,
"printer-make-and-model",
IPP_TAG_TEXT)) != NULL)
- strncpy(make_model, ippGetString(attr, 0, NULL), 256);
+ strncpy(make_model, ippGetString(attr, 0, NULL),
+ sizeof(make_model) - 1);
color = 0;
duplex = 0;
for(r = (remote_printer_t *)cupsArrayFirst(remote_printers);
@@ -8266,7 +8268,7 @@ gboolean update_cups_queues(gpointer unused) {
ap_remote_queue_id_line_inserted = 0;
while (cupsFileGets(in, line, sizeof(line))) {
if (!strncmp(line, "*Default", 8)) {
- strncpy(keyword, line + 8, sizeof(keyword));
+ strncpy(keyword, line + 8, sizeof(keyword) - 1);
if ((strlen(line) + 8) > 1023)
keyword[1023] = '\0';
for (keyptr = keyword; *keyptr; keyptr ++)
@@ -9087,7 +9089,7 @@ examine_discovered_printer_record(const char *host,
}
}
/* Extract location from DNS-SD TXT record's "note" field */
- if (!location) {
+ if (location[0] == '\0') {
if (txt) {
entry = avahi_string_list_find((AvahiStringList *)txt, "note");
if (entry) {
@@ -9101,8 +9103,6 @@ examine_discovered_printer_record(const char *host,
/* don't avahi_free(note_value) here! */
}
}
- if (!location)
- location = "";
}
/* A NULL location is only passed in from resolve_callback(), which is
HAVE_AVAHI */
@@ -9505,7 +9505,7 @@ static void resolve_callback(AvahiServiceResolver *r,
if (!if_indextoname(interface, ifname)) {
debug_printf("Unable to find interface name for interface %d: %s\n",
interface, strerror(errno));
- strncpy(ifname, "Unknown", sizeof(ifname));
+ strncpy(ifname, "Unknown", sizeof(ifname) - 1);
}
/* Ignore local queues on the port of the cupsd we are serving for */
@@ -9597,7 +9597,7 @@ static void resolve_callback(AvahiServiceResolver *r,
n = p - name;
if (n >= sizeof(instance))
n = sizeof(instance) - 1;
- strncpy(instance, name, n);
+ strncpy(instance, name, sizeof(instance) - 1);
instance[n] = '\0';
debug_printf("Avahi-Resolver: Instance: %s\n", instance); /* !! */
} else {
@@ -9629,7 +9629,7 @@ static void resolve_callback(AvahiServiceResolver *r,
address->proto == AVAHI_PROTO_INET6 &&
interface != AVAHI_IF_UNSPEC &&
IPBasedDeviceURIs != IP_BASED_URIS_IPV4_ONLY) {
- strncpy(addrstr, "[v1.", 256);
+ strncpy(addrstr, "[v1.", sizeof(addrstr) - 1);
avahi_address_snprint(addrstr + 4, 256 - 6, address);
addrlen = strlen(addrstr + 4);
addr->sa_family = AF_INET6;
@@ -9768,7 +9768,7 @@ static void browse_callback(AvahiServiceBrowser *b,
if (!if_indextoname(interface, ifname)) {
debug_printf("Unable to find interface name for interface %d: %s\n",
interface, strerror(errno));
- strncpy(ifname, "Unknown", sizeof(ifname));
+ strncpy(ifname, "Unknown", sizeof(ifname) - 1);
}
debug_printf("Avahi Browser: NEW: service '%s' of type '%s' in domain '%s' on interface '%s' (%s)\n",
@@ -9803,7 +9803,7 @@ static void browse_callback(AvahiServiceBrowser *b,
if (!if_indextoname(interface, ifname)) {
debug_printf("Unable to find interface name for interface %d: %s\n",
interface, strerror(errno));
- strncpy(ifname, "Unknown", sizeof(ifname));
+ strncpy(ifname, "Unknown", sizeof(ifname) - 1);
}
debug_printf("Avahi Browser: REMOVE: service '%s' of type '%s' in domain '%s' on interface '%s' (%s)\n",
@@ -10926,7 +10926,7 @@ read_configuration (const char *filename)
in the configuration file is used. */
while ((i < cupsArrayCount(command_line_config) &&
(value = cupsArrayIndex(command_line_config, i++)) &&
- strncpy(line, value, sizeof(line)) &&
+ strncpy(line, value, sizeof(line) - 1) &&
((strlen(value) > HTTP_MAX_BUFFER-1) ?
line[HTTP_MAX_BUFFER-1] = '\0': 1)) ||
cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) {
@@ -11757,7 +11757,8 @@ int main(int argc, char*argv[]) {
client.conf files as cups-browsed works only with a local CUPS
daemon, not with remote ones. */
if (getenv("CUPS_SERVER") != NULL) {
- strncpy(local_server_str, getenv("CUPS_SERVER"), sizeof(local_server_str));
+ strncpy(local_server_str, getenv("CUPS_SERVER"),
+ sizeof(local_server_str) - 1);
if (strlen(getenv("CUPS_SERVER")) > 1023)
local_server_str[1023] = '\0';
} else {
@@ -11772,9 +11773,11 @@ int main(int argc, char*argv[]) {
!stat(DomainSocket, &sockinfo) &&
(sockinfo.st_mode & S_IROTH) != 0 &&
(sockinfo.st_mode & S_IWOTH) != 0)
- strncpy(local_server_str, DomainSocket, sizeof(local_server_str));
+ strncpy(local_server_str, DomainSocket,
+ sizeof(local_server_str) - 1);
else
- strncpy(local_server_str, "localhost:631", sizeof(local_server_str));
+ strncpy(local_server_str, "localhost:631",
+ sizeof(local_server_str) - 1);
} else
strncpy(local_server_str, "localhost:631", sizeof(local_server_str));
setenv("CUPS_SERVER", local_server_str, 1);
diff --git a/utils/driverless.c b/utils/driverless.c
index 6a464c307..85df65750 100644
--- a/utils/driverless.c
+++ b/utils/driverless.c
@@ -223,10 +223,10 @@ list_printers (int mode)
make[0] = '\0';
pdl[0] = '\0';
device_id[0] = '\0';
- strncpy(model, "Unknown", sizeof(model));
+ strncpy(model, "Unknown", sizeof(model) - 1);
if (txt_usb_mfg[0] != '\0') {
- strncpy(make, txt_usb_mfg, sizeof(make));
+ strncpy(make, txt_usb_mfg, sizeof(make) - 1);
if (strlen(txt_usb_mfg) > 511)
make[511] = '\0';
ptr = device_id + strlen(device_id);
@@ -234,7 +234,7 @@ list_printers (int mode)
"MFG:%s;", txt_usb_mfg);
}
if (txt_usb_mdl[0] != '\0') {
- strncpy(model, txt_usb_mdl, sizeof(model));
+ strncpy(model, txt_usb_mdl, sizeof(model) - 1);
if (strlen(txt_usb_mdl) > 255)
model[255] = '\0';
ptr = device_id + strlen(device_id);
@@ -246,20 +246,20 @@ list_printers (int mode)
if ((ptr = txt_product + strlen(txt_product) - 1) > txt_product &&
*ptr == ')')
*ptr = '\0';
- strncpy(model, txt_product + 1, sizeof(model));
+ strncpy(model, txt_product + 1, sizeof(model) - 1);
if ((strlen(txt_product) + 1) > 255)
model[255] = '\0';
} else
- strncpy(model, txt_product, sizeof(model));
+ strncpy(model, txt_product, sizeof(model) - 1);
} else if (txt_ty[0] != '\0') {
- strncpy(model, txt_ty, sizeof(model));
+ strncpy(model, txt_ty, sizeof(model) - 1);
if (strlen(txt_ty) > 255)
model[255] = '\0';
if ((ptr = strchr(model, ',')) != NULL)
*ptr = '\0';
}
if (txt_pdl[0] != '\0') {
- strncpy(pdl, txt_pdl, sizeof(pdl));
+ strncpy(pdl, txt_pdl, sizeof(pdl) - 1);
if (strlen(txt_pdl) > 255)
pdl[255] = '\0';
}
@@ -329,7 +329,7 @@ list_printers (int mode)
snprintf(make_and_model, sizeof(make_and_model), "%s %s",
make, model);
else
- strncpy(make_and_model, model, sizeof(make_and_model));
+ strncpy(make_and_model, model, sizeof(make_and_model) - 1);
if (mode == 1)
/* Call with "list" argument (PPD generator in list mode */