fix printing images to Postscript printers
This commit is contained in:
parent
f43ad13cc2
commit
82826d262c
@ -1,154 +0,0 @@
|
||||
From 0d469d4fd01432462a7cf03bbb30568edb822695 Mon Sep 17 00:00:00 2001
|
||||
From: Zdenek Dohnal <zdohnal@redhat.com>
|
||||
Date: Tue, 14 Feb 2023 17:12:40 +0100
|
||||
Subject: [PATCH] Coverity fixes
|
||||
|
||||
---
|
||||
ppd/imagetops-pstops.c | 9 +++++++--
|
||||
ppd/pdftops.c | 2 ++
|
||||
ppd/ppd-collection.cxx | 5 ++++-
|
||||
ppd/ppd-filter.c | 18 +++++++++++++-----
|
||||
ppd/raster-interpret.c | 3 ++-
|
||||
5 files changed, 28 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/ppd/imagetops-pstops.c b/ppd/imagetops-pstops.c
|
||||
index 7c5023d3..948ca0df 100644
|
||||
--- a/ppd/imagetops-pstops.c
|
||||
+++ b/ppd/imagetops-pstops.c
|
||||
@@ -280,7 +280,6 @@ ppdFilterPSToPS(int inputfd, // I - File descriptor input stream
|
||||
log, ld, iscanceled, icd) == 1)
|
||||
{
|
||||
close(inputfd);
|
||||
- close(outputfd);
|
||||
|
||||
return (1);
|
||||
}
|
||||
@@ -401,6 +400,10 @@ ppdFilterPSToPS(int inputfd, // I - File descriptor input stream
|
||||
"ppdFilterPSToPS: The print file is empty.");
|
||||
// Do not treat this an error, if a previous filter eliminated all
|
||||
// pages the job should get dequeued without anything printed.
|
||||
+
|
||||
+ fclose(outputfp);
|
||||
+ cupsFileClose(inputfp);
|
||||
+
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -564,7 +567,6 @@ ppdFilterPSToPS(int inputfd, // I - File descriptor input stream
|
||||
close(inputfd);
|
||||
|
||||
fclose(outputfp);
|
||||
- close(outputfd);
|
||||
|
||||
return (status);
|
||||
}
|
||||
@@ -704,6 +706,9 @@ ppdFilterImageToPS(int inputfd, // I - File descriptor input
|
||||
if (log) log(ld, CF_LOGLEVEL_ERROR,
|
||||
"ppdFilterImageToPS: Unable to copy input: %s",
|
||||
strerror(errno));
|
||||
+
|
||||
+ fclose(inputfp);
|
||||
+
|
||||
return (1);
|
||||
}
|
||||
|
||||
diff --git a/ppd/pdftops.c b/ppd/pdftops.c
|
||||
index a00b2260..c88d9ad9 100644
|
||||
--- a/ppd/pdftops.c
|
||||
+++ b/ppd/pdftops.c
|
||||
@@ -373,6 +373,8 @@ ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream
|
||||
{
|
||||
if (log) log(ld, CF_LOGLEVEL_ERROR,
|
||||
"ppdFilterPDFToPS: Unable to copy PDF file: %s", strerror(errno));
|
||||
+
|
||||
+ fclose(inputfp);
|
||||
return (1);
|
||||
}
|
||||
|
||||
diff --git a/ppd/ppd-collection.cxx b/ppd/ppd-collection.cxx
|
||||
index 68ea4db1..27a0b011 100644
|
||||
--- a/ppd/ppd-collection.cxx
|
||||
+++ b/ppd/ppd-collection.cxx
|
||||
@@ -1573,8 +1573,11 @@ load_drv(const char *filename, // I - Actual filename
|
||||
mtime, (size_t)size, d->model_number, type, "drv",
|
||||
ppdlist, log, ld);
|
||||
else if (products_found < PPD_MAX_PROD)
|
||||
+ {
|
||||
strncpy(ppd->record.products[products_found], product->value->value,
|
||||
- sizeof(ppd->record.products[0]));
|
||||
+ sizeof(ppd->record.products[0]) - 1);
|
||||
+ ppd->record.products[products_found][sizeof(ppd->record.products[0]) - 1] = '\0';
|
||||
+ }
|
||||
else
|
||||
break;
|
||||
|
||||
diff --git a/ppd/ppd-filter.c b/ppd/ppd-filter.c
|
||||
index 4e2d2931..308336ad 100644
|
||||
--- a/ppd/ppd-filter.c
|
||||
+++ b/ppd/ppd-filter.c
|
||||
@@ -46,6 +46,7 @@ ppdFilterCUPSWrapper(
|
||||
cups_option_t *options = NULL; // Print options
|
||||
cf_filter_data_t filter_data;
|
||||
const char *val;
|
||||
+ char *ppdfile = NULL;
|
||||
char buf[256];
|
||||
int retval = 0;
|
||||
|
||||
@@ -161,20 +162,26 @@ ppdFilterCUPSWrapper(
|
||||
// to the filter_data structure
|
||||
//
|
||||
|
||||
- if (getenv("PPD"))
|
||||
- retval = ppdFilterLoadPPDFile(&filter_data, getenv("PPD"));
|
||||
+ ppdfile = getenv("PPD");
|
||||
+
|
||||
+ if (ppdfile && (retval = ppdFilterLoadPPDFile(&filter_data, getenv("PPD"))) != 0)
|
||||
+ {
|
||||
+ fprintf(stderr, "ERROR: ppdFilterCUPSWrapper: Cannot open the PPD file %s\n", ppdfile);
|
||||
+ close(inputfd);
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
//
|
||||
// Fire up the filter function (output to stdout, file descriptor 1)
|
||||
//
|
||||
|
||||
- if (!retval)
|
||||
- retval = filter(inputfd, 1, inputseekable, &filter_data, parameters);
|
||||
+ retval = filter(inputfd, 1, inputseekable, &filter_data, parameters);
|
||||
|
||||
//
|
||||
// Clean up
|
||||
//
|
||||
|
||||
+out:
|
||||
cupsFreeOptions(filter_data.num_options, filter_data.options);
|
||||
ppdFilterFreePPDFile(&filter_data);
|
||||
|
||||
@@ -1570,7 +1577,8 @@ ppdFilterUniversal(int inputfd, // I - File descriptor input stream
|
||||
if (log) log(ld, CF_LOGLEVEL_DEBUG,
|
||||
"ppdFilterUniversal: --> Selecting this line");
|
||||
// Take the input format of the line as output format for us
|
||||
- strncpy(output, in, sizeof(output));
|
||||
+ strncpy(output, in, sizeof(output) - 1);
|
||||
+ output[sizeof(output) - 1] = '\0';
|
||||
// Update the minimum cost found
|
||||
lowest_cost = cost;
|
||||
// We cannot find a "better" solution ...
|
||||
diff --git a/ppd/raster-interpret.c b/ppd/raster-interpret.c
|
||||
index efa99d7e..cff216e7 100644
|
||||
--- a/ppd/raster-interpret.c
|
||||
+++ b/ppd/raster-interpret.c
|
||||
@@ -526,7 +526,8 @@ ppdRasterMatchPPDSize(
|
||||
return (-1);
|
||||
}
|
||||
|
||||
- strncpy(pageSizeRequested, header->cupsPageSizeName, 64);
|
||||
+ strncpy(pageSizeRequested, header->cupsPageSizeName, 63);
|
||||
+ pageSizeRequested[63] = "\0";
|
||||
// Prefer user-selected page size.
|
||||
memset(dimensions, 0, sizeof(double)*2);
|
||||
memset(margins, 0, sizeof(double)*4);
|
||||
--
|
||||
2.39.1
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
From b815415c74a8e5112ca9bd8adc7c04f626ec4702 Mon Sep 17 00:00:00 2001
|
||||
From: Zdenek Dohnal <zdohnal@redhat.com>
|
||||
Date: Wed, 15 Mar 2023 16:37:06 +0100
|
||||
Subject: [PATCH] ppd-filter.c: Generate media-col if media-col-default exists
|
||||
|
||||
We would generate `media-col` attribute only if we had `media-col-default`
|
||||
attribute and `PageSize` or `media` options, which doesn't seem to be always
|
||||
the case for `PageSize` and `media`. These options usually are not
|
||||
default options and if the application doesn't send them, they are not
|
||||
sent to filters.
|
||||
|
||||
The current implementation breaks image printing for (at least) printers
|
||||
installed with Postscript driver - the printer outputs an empty sheet of
|
||||
paper. It happens because `cfFilterImageToPDF()` doesn't get page size
|
||||
by other means.
|
||||
---
|
||||
ppd/ppd-filter.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ppd/ppd-filter.c b/ppd/ppd-filter.c
|
||||
index 308336ad..fbf2e4f8 100644
|
||||
--- a/ppd/ppd-filter.c
|
||||
+++ b/ppd/ppd-filter.c
|
||||
@@ -739,9 +739,8 @@ ppdFilterLoadPPD(cf_filter_data_t *data) // I/O - Job and printer data
|
||||
|
||||
page_size = cupsGetOption("PageSize", data->num_options, data->options);
|
||||
media = cupsGetOption("media", data->num_options, data->options);
|
||||
- if ((page_size || media) &&
|
||||
- (attr = ippFindAttribute(data->printer_attrs, "media-col-default",
|
||||
- IPP_TAG_ZERO)) != NULL)
|
||||
+ if ((attr = ippFindAttribute(data->printer_attrs, "media-col-default",
|
||||
+ IPP_TAG_ZERO)) != NULL)
|
||||
{
|
||||
// We have already applied the settings of these options to the
|
||||
// PPD file and converted the PPD option settings into the printer
|
||||
--
|
||||
2.40.0
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
Name: libppd
|
||||
Epoch: 1
|
||||
Version: 2.0~b4
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: Library for retro-fitting legacy printer drivers
|
||||
|
||||
# the CUPS exception text is the same as LLVM exception, so using that name with
|
||||
@ -20,6 +20,8 @@ Source0: %{URL}/releases/download/%{upstream_version}/%{name}-%{upstream_
|
||||
|
||||
|
||||
# Patches
|
||||
# https://github.com/OpenPrinting/libppd/pull/15
|
||||
Patch0001: 0001-ppd-filter.c-Generate-media-col-if-media-col-default.patch
|
||||
|
||||
|
||||
# for autogen.sh
|
||||
@ -189,6 +191,9 @@ rm -rf %{buildroot}%{_datadir}/ppdc
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Mar 15 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.0~b4-2
|
||||
- fix printing images to Postscript printers
|
||||
|
||||
* Wed Mar 01 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.0~b4-1
|
||||
- 2.0b4
|
||||
- introduce Epoch because I didn't read FPG carefully...
|
||||
|
||||
Loading…
Reference in New Issue
Block a user