OBS User unknown 2008-04-25 14:01:41 +00:00 committed by Git OBS Bridge
parent bc6d5a7a37
commit 7c8207e514
7 changed files with 269 additions and 91 deletions

View File

@ -0,0 +1,61 @@
--- cups-1.3.7/filter/image-png.c.orig 2007-07-11 23:46:42.000000000 +0200
+++ cups-1.3.7/filter/image-png.c 2008-04-16 12:04:14.000000000 +0200
@@ -170,16 +170,56 @@
* Interlaced images must be loaded all at once...
*/
+ size_t bufsize; /* Size of buffer */
+
+
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- in = malloc(img->xsize * img->ysize);
+ {
+ bufsize = img->xsize * img->ysize;
+
+ if ((bufsize / img->ysize) != img->xsize)
+ {
+ fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
+ (unsigned)width, (unsigned)height);
+ fclose(fp);
+ return (1);
+ }
+ }
else
- in = malloc(img->xsize * img->ysize * 3);
+ {
+ bufsize = img->xsize * img->ysize * 3;
+
+ if ((bufsize / (img->ysize * 3)) != img->xsize)
+ {
+ fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
+ (unsigned)width, (unsigned)height);
+ fclose(fp);
+ return (1);
+ }
+ }
+
+ in = malloc(bufsize);
}
bpp = cupsImageGetDepth(img);
out = malloc(img->xsize * bpp);
+ if (!in || !out)
+ {
+ fputs("DEBUG: Unable to allocate memory for PNG image!\n", stderr);
+
+ if (in)
+ free(in);
+
+ if (out)
+ free(out);
+
+ fclose(fp);
+
+ return (1);
+ }
+
/*
* Read the image, interlacing as needed...
*/

View File

@ -1,5 +1,5 @@
/*
* "$Id: pdftops.c 7391 2008-03-21 21:24:18Z mike $"
* "$Id: pdftops.c 7449 2008-04-14 18:27:53Z mike $"
*
* PDF to PostScript filter front-end for the Common UNIX Printing
* System (CUPS).
@ -28,6 +28,7 @@
#include <cups/i18n.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
/*
@ -37,6 +38,13 @@
static void cancel_job(int sig);
/*
* Local globals...
*/
static int job_canceled = 0;
/*
* 'main()' - Main entry for filter...
*/
@ -57,11 +65,16 @@ main(int argc, /* I - Number of command-line args */
ppd_file_t *ppd; /* PPD file */
ppd_size_t *size; /* Current page size */
int pdfpid, /* Process ID for pdftops */
pdfwaitpid, /* Process ID from wait() */
pdfstatus, /* Status from pdftops */
pdfargc; /* Number of args for pdftops */
char *pdfargv[100], /* Arguments for pdftops */
char *pdfargv[100], /* Arguments for pdftops/gs */
#ifdef HAVE_PDFTOPS
pdfwidth[255], /* Paper width */
pdfheight[255]; /* Paper height */
#else
pdfgeometry[255]; /* Paper width and height */
#endif /* HAVE_PDFTOPS */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
@ -148,11 +161,22 @@ main(int argc, /* I - Number of command-line args */
cupsMarkOptions(ppd, num_options, options);
/*
* Build the command-line for the pdftops filter...
* Build the command-line for the pdftops or gs filter...
*/
#ifdef HAVE_PDFTOPS
pdfargv[0] = (char *)"pdftops";
pdfargc = 1;
#else
pdfargv[0] = (char *)"gs";
pdfargv[1] = (char *)"-q";
pdfargv[2] = (char *)"-dNOPAUSE";
pdfargv[3] = (char *)"-dBATCH";
pdfargv[4] = (char *)"-dSAFER";
pdfargv[5] = (char *)"-sDEVICE=pswrite";
pdfargv[6] = (char *)"-sOUTPUTFILE=%stdout";
pdfargc = 7;
#endif /* HAVE_PDFTOPS */
if (ppd)
{
@ -162,17 +186,29 @@ main(int argc, /* I - Number of command-line args */
if (ppd->language_level == 1)
{
#ifdef HAVE_PDFTOPS
pdfargv[pdfargc++] = (char *)"-level1";
pdfargv[pdfargc++] = (char *)"-noembtt";
#else
pdfargv[pdfargc++] = (char *)"-dLanguageLevel=1";
#endif /* HAVE_PDFTOPS */
}
else if (ppd->language_level == 2)
{
#ifdef HAVE_PDFTOPS
pdfargv[pdfargc++] = (char *)"-level2";
if (!ppd->ttrasterizer)
pdfargv[pdfargc++] = (char *)"-noembtt";
#else
pdfargv[pdfargc++] = (char *)"-dLanguageLevel=2";
#endif /* HAVE_PDFTOPS */
}
else
#ifdef HAVE_PDFTOPS
pdfargv[pdfargc++] = (char *)"-level3";
#else
pdfargv[pdfargc++] = (char *)"-dLanguageLevel=3";
#endif /* HAVE_PDFTOPS */
/*
* Set output page size...
@ -209,6 +245,7 @@ main(int argc, /* I - Number of command-line args */
orientation ^= 1;
}
#ifdef HAVE_PDFTOPS
if (orientation & 1)
{
snprintf(pdfwidth, sizeof(pdfwidth), "%.0f", size->length);
@ -224,9 +261,20 @@ main(int argc, /* I - Number of command-line args */
pdfargv[pdfargc++] = pdfwidth;
pdfargv[pdfargc++] = (char *)"-paperh";
pdfargv[pdfargc++] = pdfheight;
#else
if (orientation & 1)
snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->length,
size->width);
else
snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->width,
size->length);
pdfargv[pdfargc++] = pdfgeometry;
#endif /* HAVE_PDFTOPS */
}
}
#ifdef HAVE_PDFTOPS
if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
strcasecmp(val, "no") && strcasecmp(val, "off") &&
strcasecmp(val, "false"))
@ -234,7 +282,14 @@ main(int argc, /* I - Number of command-line args */
pdfargv[pdfargc++] = filename;
pdfargv[pdfargc++] = (char *)"-";
pdfargv[pdfargc] = NULL;
#else
pdfargv[pdfargc++] = (char *)"-c";
pdfargv[pdfargc++] = (char *)"save pop";
pdfargv[pdfargc++] = (char *)"-f";
pdfargv[pdfargc++] = filename;
#endif /* HAVE_PDFTOPS */
pdfargv[pdfargc] = NULL;
if ((pdfpid = fork()) == 0)
{
@ -242,8 +297,14 @@ main(int argc, /* I - Number of command-line args */
* Child comes here...
*/
#ifdef HAVE_PDFTOPS
execv(CUPS_PDFTOPS, pdfargv);
_cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
_cupsLangPrintError(_("ERROR: Unable to execute pdftops program"));
#else
execv(CUPS_GHOSTSCRIPT, pdfargv);
_cupsLangPrintError(_("ERROR: Unable to execute gs program"));
#endif /* HAVE_PDFTOPS */
exit(1);
}
else if (pdfpid < 0)
@ -252,7 +313,12 @@ main(int argc, /* I - Number of command-line args */
* Unable to fork!
*/
_cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
#ifdef HAVE_PDFTOPS
_cupsLangPrintError(_("ERROR: Unable to execute pdftops program"));
#else
_cupsLangPrintError(_("ERROR: Unable to execute gs program"));
#endif /* HAVE_PDFTOPS */
pdfstatus = 1;
}
else
@ -261,7 +327,17 @@ main(int argc, /* I - Number of command-line args */
* Parent comes here...
*/
if (wait(&pdfstatus) != pdfpid)
while ((pdfwaitpid = wait(&pdfstatus)) < 0 && errno == EINTR)
{
/*
* Wait until we get a valid process ID or the job is canceled...
*/
if (job_canceled)
break;
}
if (pdfwaitpid != pdfpid)
{
kill(pdfpid, SIGTERM);
pdfstatus = 1;
@ -270,18 +346,18 @@ main(int argc, /* I - Number of command-line args */
{
if (WIFEXITED(pdfstatus))
{
pdfstatus = WEXITSTATUS(pdfstatus);
pdfstatus = WEXITSTATUS(pdfstatus);
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter exited with status %d!\n"),
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter exited with status %d!\n"),
pdfstatus);
}
else
{
pdfstatus = WTERMSIG(pdfstatus);
pdfstatus = WTERMSIG(pdfstatus);
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter crashed on signal %d!\n"),
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter crashed on signal %d!\n"),
pdfstatus);
}
}
@ -306,9 +382,11 @@ static void
cancel_job(int sig) /* I - Signal number (unused) */
{
(void)sig;
job_canceled = 1;
}
/*
* End of "$Id: pdftops.c 7391 2008-03-21 21:24:18Z mike $".
* End of "$Id: pdftops.c 7449 2008-04-14 18:27:53Z mike $".
*/

View File

@ -99,35 +99,6 @@
/*
* Do we have Darwin's CoreFoundation and SystemConfiguration frameworks?
--- cups-1.3.7/filter/pdftops.c.orig 2008-04-09 18:23:35.000000000 +0200
+++ cups-1.3.7/filter/pdftops.c 2008-04-09 18:33:53.000000000 +0200
@@ -115,7 +115,7 @@
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
- _cupsLangPrintError(_("ERROR: Unable to copy PDF file"));
+ perror(_("ERROR: Unable to copy PDF file"));
return (1);
}
@@ -245,7 +245,7 @@
*/
execv(CUPS_PDFTOPS, pdfargv);
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
+ perror(_("ERROR: Unable to execute pdftops filter"));
exit(1);
}
else if (pdfpid < 0)
@@ -254,7 +254,7 @@
* Unable to fork!
*/
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
+ perror(_("ERROR: Unable to execute pdftops filter"));
pdfstatus = 1;
}
else
--- cups-1.3.7/Makefile.orig 2008-02-16 00:26:51.000000000 +0100
+++ cups-1.3.7/Makefile 2008-04-09 19:08:39.000000000 +0200
@@ -20,7 +20,7 @@
@ -139,3 +110,50 @@
$(PHPDIR) \
conf data doc $(FONTS) ppd templates
--- cups-1.3.7/filter/pdftops.c.orig 2008-04-22 20:18:35.000000000 +0200
+++ cups-1.3.7/filter/pdftops.c 2008-04-22 20:22:09.000000000 +0200
@@ -126,7 +126,7 @@ main(int argc, /* I - Number of comm
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
- _cupsLangPrintError(_("ERROR: Unable to copy PDF file"));
+ perror(_("ERROR: Unable to copy PDF file"));
return (1);
}
@@ -299,10 +299,10 @@ main(int argc, /* I - Number of comm
#ifdef HAVE_PDFTOPS
execv(CUPS_PDFTOPS, pdfargv);
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops program"));
+ perror("ERROR: Unable to execute pdftops program");
#else
execv(CUPS_GHOSTSCRIPT, pdfargv);
- _cupsLangPrintError(_("ERROR: Unable to execute gs program"));
+ perror("ERROR: Unable to execute gs program");
#endif /* HAVE_PDFTOPS */
exit(1);
@@ -314,9 +314,9 @@ main(int argc, /* I - Number of comm
*/
#ifdef HAVE_PDFTOPS
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops program"));
+ perror("ERROR: Unable to execute pdftops program");
#else
- _cupsLangPrintError(_("ERROR: Unable to execute gs program"));
+ perror("ERROR: Unable to execute gs program");
#endif /* HAVE_PDFTOPS */
pdfstatus = 1;
--- cups-1.3.7/filter/pdftops.c.orig 2008-04-22 20:24:15.000000000 +0200
+++ cups-1.3.7/filter/pdftops.c 2008-04-22 20:26:20.000000000 +0200
@@ -301,7 +301,7 @@ main(int argc, /* I - Number of comm
execv(CUPS_PDFTOPS, pdfargv);
perror("ERROR: Unable to execute pdftops program");
#else
- execv(CUPS_GHOSTSCRIPT, pdfargv);
+ execv("/bin/sgs", pdfargv);
perror("ERROR: Unable to execute gs program");
#endif /* HAVE_PDFTOPS */

View File

@ -0,0 +1,34 @@
Index: pdftops.c
===================================================================
--- cups-1.4svn/filter/pdftops.c (revision 7480)
+++ cups-1.4svn/filter/pdftops.c (revision 7481)
@@ -327,23 +327,21 @@
* Parent comes here...
*/
- while ((pdfwaitpid = wait(&pdfstatus)) < 0 && errno == EINTR)
+ while ((pdfwaitpid = wait(&pdfstatus)) != pdfpid && errno == EINTR)
{
/*
* Wait until we get a valid process ID or the job is canceled...
*/
if (job_canceled)
- break;
+ {
+ kill(pdfpid, SIGTERM);
+ job_canceled = 0;
+ }
}
- if (pdfwaitpid != pdfpid)
+ if (pdfstatus)
{
- kill(pdfpid, SIGTERM);
- pdfstatus = 1;
- }
- else if (pdfstatus)
- {
if (WIFEXITED(pdfstatus))
{
pdfstatus = WEXITSTATUS(pdfstatus);

View File

@ -1,40 +0,0 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## pdftops-wait-eintr.dpatch by <mpitt@debian.org>
##
## DP: Handle EINTR in pdftops' wait() call.
@DPATCH@
diff -urNad trunk~/filter/pdftops.c trunk/filter/pdftops.c
--- trunk~/filter/pdftops.c 2008-04-02 02:54:45.000000000 +0200
+++ trunk/filter/pdftops.c 2008-04-02 02:54:59.000000000 +0200
@@ -28,6 +28,7 @@
#include <cups/i18n.h>
#include <signal.h>
#include <sys/wait.h>
+#include <errno.h>
/*
@@ -62,6 +63,7 @@
char *pdfargv[100], /* Arguments for pdftops */
pdfwidth[255], /* Paper width */
pdfheight[255]; /* Paper height */
+ pid_t child; /* wait() result */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
@@ -260,8 +262,13 @@
/*
* Parent comes here...
*/
+
+ do
+ {
+ child = wait(&pdfstatus);
+ } while (child < 0 && errno == EINTR);
- if (wait(&pdfstatus) != pdfpid)
+ if (child != pdfpid)
{
kill(pdfpid, SIGTERM);
pdfstatus = 1;

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Tue Apr 22 20:24:19 CEST 2008 - kssingvo@suse.de
- new version of pdftops filter from svn extracted
- changed the perror() calls in pdftops.c for cups-1.3.x compatibility
- fixed the ghostscript call via new variable (unnecessary -> removed)
- grabbed and applied the wait() fix for childs from cups STR
-------------------------------------------------------------------
Wed Apr 16 12:06:57 CEST 2008 - kssingvo@suse.de
- fix for integer overflow in png filter CVE-2008-1722 (bugzilla#378335)
- not affected: CVE-2008-1693 (bugzilla#377872)
- added /usr/bin/pdftops to Requires:, and poppler-tools to Suggests:
-------------------------------------------------------------------
Fri Apr 11 11:06:33 CEST 2008 - ro@suse.de

View File

@ -22,10 +22,11 @@ License: GPL v2 or later
Group: Hardware/Printing
Summary: The Common UNIX Printing System
Version: 1.3.7
Release: 8
Release: 11
Requires: cups-libs = %{version}, cups-client = %{version}
Requires: ghostscript_any, ghostscript-fonts-std, foomatic-filters
Requires: util-linux
Requires: util-linux /usr/bin/pdftops
Suggests: poppler-tools
Conflicts: plp lprold lprng
Source0: cups-%{version}-source.tar.bz2
Source1: poll_ppd_base.c
@ -63,9 +64,10 @@ Patch15: cups-1.2.11-testppd_filename.patch
Patch16: cups-1.2.5-desktop_file.patch
Patch17: cups-1.3.3-testppd_none.patch
Patch18: cups-1.4svn-pdftops_as_filter.patch
# next is found as http://www.cups.org/strfiles/2780/pdftops-wait-eintr.dpatch
Patch19: cups-1.4svn-pdftops_wait_eintr.patch
Patch20: cups-hardcode_pdftops.patch
Patch19: cups-hardcode_pdftops.patch
Patch20: cups-1.3.7-filter_png_overflow.patch
# next is found as http://www.cups.org/strfiles/2808/str2808.patch
Patch21: cups-1.4svn-pdftops_dont_fail_on_cancel.patch
Patch100: cups-1.1.23-testpage.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -146,7 +148,7 @@ Authors:
%prep
%setup -n %{name}-%{version}
%{INSTALL_DATA} %{SOURCE22} filter/pdftops.c
# just to make avoid misunderstandings...
# just to avoid misunderstandings...
mv pdftops pdftos.use_filter_pdftops_c
%patch1 -p1
%patch2 -p1
@ -163,8 +165,9 @@ mv pdftops pdftos.use_filter_pdftops_c
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20
%patch19
%patch20 -p1
%patch21 -p1
if [ -f /.buildenv ]; then
. /.buildenv
else
@ -420,6 +423,15 @@ rm -rf $RPM_BUILD_ROOT/usr/share/locale/no
%{_datadir}/locale/*/cups_*
%changelog
* Tue Apr 22 2008 kssingvo@suse.de
- new version of pdftops filter from svn extracted
- changed the perror() calls in pdftops.c for cups-1.3.x compatibility
- fixed the ghostscript call via new variable (unnecessary -> removed)
- grabbed and applied the wait() fix for childs from cups STR
* Wed Apr 16 2008 kssingvo@suse.de
- fix for integer overflow in png filter CVE-2008-1722 (bugzilla#378335)
- not affected: CVE-2008-1693 (bugzilla#377872)
- added /usr/bin/pdftops to Requires:, and poppler-tools to Suggests:
* Fri Apr 11 2008 ro@suse.de
- explicitly specify pdftops binary for configure to avoid
adding buildrequires just for a binary path