From 972caf59acdb37f7e213de8bb07f86a8d551a200 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 29 Sep 2009 04:56:28 +0000 Subject: [PATCH 01/19] Initialize branch F-12 for ghostscript --- branch | 1 + 1 file changed, 1 insertion(+) create mode 100644 branch diff --git a/branch b/branch new file mode 100644 index 0000000..06de2d2 --- /dev/null +++ b/branch @@ -0,0 +1 @@ +F-12 From 2656f78197b559db262fec6c596e1111424d517d Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 26 Nov 2009 01:56:17 +0000 Subject: [PATCH 02/19] Fix typo that causes a failure to update the common directory. (releng #2781) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 903ac9b..ad9af45 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ # Makefile for source rpm: ghostscript -# $Id: Makefile,v 1.1 2004/09/09 05:07:56 cvsdist Exp $ +# $Id: Makefile,v 1.2 2007/10/15 18:47:19 notting Exp $ NAME := ghostscript SPECFILE = $(firstword $(wildcard *.spec)) define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done endef MAKEFILE_COMMON := $(shell $(find-makefile-common)) From 59db7de965af35ce80e9bf6080957e9ae95a67c3 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Thu, 24 Dec 2009 11:31:29 +0000 Subject: [PATCH 03/19] - Fix debugging output from gdevcups (CVE-2009-4270, bug #540760). - Harden ghostscript's debugging output functions (bug #540760). --- ghostscript-CVE-2009-4270.patch | 17 +++++++++ ghostscript-vsnprintf.patch | 64 +++++++++++++++++++++++++++++++++ ghostscript.spec | 14 +++++++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 ghostscript-CVE-2009-4270.patch create mode 100644 ghostscript-vsnprintf.patch diff --git a/ghostscript-CVE-2009-4270.patch b/ghostscript-CVE-2009-4270.patch new file mode 100644 index 0000000..c498feb --- /dev/null +++ b/ghostscript-CVE-2009-4270.patch @@ -0,0 +1,17 @@ +diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-debug ghostscript-8.70/cups/gdevcups.c +--- ghostscript-8.70/cups/gdevcups.c.gdevcups-debug 2009-05-20 23:30:48.000000000 +0100 ++++ ghostscript-8.70/cups/gdevcups.c 2009-11-24 17:16:11.929250977 +0000 +@@ -2816,11 +2816,11 @@ cups_put_params(gx_device *pdev, /* + } \ + else if (code == 0) \ + { \ +- dprintf2("DEBUG: Setting %s to \"%s\"...\n", sname, \ +- (char *)stringval.data); \ + strncpy(cups->header.name, (const char *)stringval.data, \ + stringval.size); \ + cups->header.name[stringval.size] = '\0'; \ ++ dprintf2("DEBUG: Setting %s to \"%s\"...\n", sname, \ ++ cups->header.name); \ + } + + #define intoption(name, sname, type) \ diff --git a/ghostscript-vsnprintf.patch b/ghostscript-vsnprintf.patch new file mode 100644 index 0000000..a7fac21 --- /dev/null +++ b/ghostscript-vsnprintf.patch @@ -0,0 +1,64 @@ +diff -up ghostscript-8.70/base/gsmisc.c.vsnprintf ghostscript-8.70/base/gsmisc.c +--- ghostscript-8.70/base/gsmisc.c.vsnprintf 2008-01-07 18:43:02.000000000 +0000 ++++ ghostscript-8.70/base/gsmisc.c 2009-11-24 17:16:38.575250571 +0000 +@@ -69,10 +69,10 @@ int outprintf(const gs_memory_t *mem, co + + va_start(args, fmt); + +- count = vsprintf(buf, fmt, args); ++ count = vsnprintf(buf, sizeof (buf), fmt, args); + outwrite(mem, buf, count); +- if (count >= PRINTF_BUF_LENGTH) { +- count = sprintf(buf, ++ if (count == -1 || count >= sizeof (buf)) { ++ count = snprintf(buf, sizeof (buf), + "PANIC: printf exceeded %d bytes. Stack has been corrupted.\n", + PRINTF_BUF_LENGTH); + outwrite(mem, buf, count); +@@ -89,10 +89,10 @@ int errprintf(const char *fmt, ...) + + va_start(args, fmt); + +- count = vsprintf(buf, fmt, args); ++ count = vsnprintf(buf, sizeof (buf), fmt, args); + errwrite(buf, count); +- if (count >= PRINTF_BUF_LENGTH) { +- count = sprintf(buf, ++ if (count == -1 || count >= sizeof (buf)) { ++ count = snprintf(buf, sizeof (buf), + "PANIC: printf exceeded %d bytes. Stack has been corrupted.\n", + PRINTF_BUF_LENGTH); + errwrite(buf, count); +@@ -236,7 +236,7 @@ int gs_throw_imp(const char *func, const + va_list ap; + + va_start(ap, fmt); +- vsprintf(msg, fmt, ap); ++ vsnprintf(msg, sizeof (msg), fmt, ap); + msg[sizeof(msg) - 1] = 0; + va_end(ap); + +diff -up ghostscript-8.70/base/gxttfb.c.vsnprintf ghostscript-8.70/base/gxttfb.c +--- ghostscript-8.70/base/gxttfb.c.vsnprintf 2009-07-09 06:59:44.000000000 +0100 ++++ ghostscript-8.70/base/gxttfb.c 2009-11-24 17:16:38.577250996 +0000 +@@ -246,7 +246,7 @@ static int DebugPrint(ttfFont *ttf, cons + + if (gs_debug_c('Y')) { + va_start(args, fmt); +- count = vsprintf(buf, fmt, args); ++ count = vsnprintf(buf, sizeof (buf), fmt, args); + /* NB: moved debug output from stdout to stderr + */ + errwrite(buf, count); +diff -up ghostscript-8.70/base/rinkj/rinkj-byte-stream.c.vsnprintf ghostscript-8.70/base/rinkj/rinkj-byte-stream.c +--- ghostscript-8.70/base/rinkj/rinkj-byte-stream.c.vsnprintf 2008-04-04 02:02:16.000000000 +0100 ++++ ghostscript-8.70/base/rinkj/rinkj-byte-stream.c 2009-11-24 17:16:38.577250996 +0000 +@@ -43,7 +43,7 @@ rinkj_byte_stream_printf (RinkjByteStrea + va_list ap; + + va_start (ap, fmt); +- len = vsprintf (str, fmt, ap); ++ len = vsnprintf (str, sizeof (str), fmt, ap); + va_end (ap); + return rinkj_byte_stream_write (bs, str, len); + } diff --git a/ghostscript.spec b/ghostscript.spec index f25231a..1e3bba6 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 1%{?dist} +Release: 2%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -25,6 +25,8 @@ Patch6: ghostscript-system-jasper.patch Patch7: ghostscript-pksmraw.patch Patch8: ghostscript-jbig2dec-nullderef.patch Patch9: ghostscript-gs-executable.patch +Patch10: ghostscript-CVE-2009-4270.patch +Patch11: ghostscript-vsnprintf.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -115,6 +117,12 @@ rm -rf libpng zlib jpeg jasper # Fix scripts so they don't get broken on install (bug #502550). %patch9 -p1 -b .gs-executable +# Fix debugging output from gdevcups (bug #540760). +%patch10 -p1 -b .CVE-2009-4270 + +# Harden ghostscript's debugging output functions (bug #540760). +%patch11 -p1 -b .vsnprintf + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -296,6 +304,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Thu Dec 24 2009 Tim Waugh 8.70-2 +- Fix debugging output from gdevcups (CVE-2009-4270, bug #540760). +- Harden ghostscript's debugging output functions (bug #540760). + * Mon Aug 3 2009 Tim Waugh 8.70-1 - 8.70. - License has changed to GPLv3+. Packages containing programs that From a1afccab2e04d475a65b19d42c0258a9ef207646 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Thu, 21 Jan 2010 13:27:43 +0000 Subject: [PATCH 04/19] - Fixed gdevcups duplex output (bug #541604) by backporting upstream revision 10625. --- ghostscript-gdevcups-y-axis.patch | 698 ++++++++++++++++++++++++++++++ ghostscript.spec | 11 +- 2 files changed, 708 insertions(+), 1 deletion(-) create mode 100644 ghostscript-gdevcups-y-axis.patch diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch new file mode 100644 index 0000000..6e92ca1 --- /dev/null +++ b/ghostscript-gdevcups-y-axis.patch @@ -0,0 +1,698 @@ +diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/gdevcups.c +--- ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis 2010-01-21 11:17:55.974149011 +0000 ++++ ghostscript-8.70/cups/gdevcups.c 2010-01-21 11:18:54.823149257 +0000 +@@ -605,8 +605,6 @@ private void + cups_get_matrix(gx_device *pdev, /* I - Device info */ + gs_matrix *pmat) /* O - Physical transform matrix */ + { +- ppd_attr_t *backside = NULL; +- + dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat); + + /* +@@ -620,119 +618,25 @@ cups_get_matrix(gx_device *pdev, /* I - + * Set the transform matrix... + */ + +- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); +- dprintf1("DEBUG2: cups->page = %d\n", cups->page); +- +- if (cupsPPD) +- { +- backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); +- if (backside) { +- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); +- cupsPPD->flip_duplex = 0; +- } +- dprintf1("DEBUG2: cupsPPD->flip_duplex = %d\n", cupsPPD->flip_duplex); +- } +- + if (cups->landscape) + { + /* + * Do landscape orientation... + */ +- +- if (cups->header.Duplex && cupsPPD && +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- (!cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && !strcasecmp(backside->value, "Rotated")))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; +- } +- else +- { +- pmat->xx = 0.0; +- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; +- } +- } +- else if (cups->header.Duplex && cupsPPD && +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[1] - pdev->HWMargins[3]) / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- (!cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && !strcasecmp(backside->value, "Rotated")))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; ++ dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n"); ++ pmat->xx = 0.0; ++ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; + } + else + { ++ /* ++ * Do portrait orientation... ++ */ ++ dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n"); + pmat->xx = (float)cups->header.HWResolution[0] / 72.0; + pmat->xy = 0.0; + pmat->yx = 0.0; +@@ -2799,6 +2703,7 @@ cups_put_params(gx_device *pdev, /* + int xflip = 0, + yflip = 0; + int found = 0; ++ static int lastpage = 0; + + dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); + +@@ -2895,6 +2800,15 @@ cups_put_params(gx_device *pdev, /* + size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 || + param_read_float_array(plist, "PageSize", &arrayval) == 0; + margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; ++ /* We also recompute page size and margins if we simply get onto a new ++ page without necessarily having a page size change in the PostScript ++ code, as for some printers margins have to flipped on the back sides of ++ the sheets (even pages) when printing duplex */ ++ if (cups->page != lastpage) { ++ size_set = 1; ++ margins_set = 1; ++ lastpage = cups->page; ++ } + color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || + param_read_int(plist, "cupsBitsPerColor", &intval) == 0; + +@@ -2995,7 +2909,7 @@ cups_put_params(gx_device *pdev, /* + * Update margins/sizes as needed... + */ + +- if (size_set) ++ if (size_set || margins_set) + { + /* + * Compute the page margins... +@@ -3011,6 +2925,7 @@ cups_put_params(gx_device *pdev, /* + if (cupsPPD != NULL) + { + dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); + dprintf1("DEBUG2: cups->page = %d\n", cups->page); + dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); + +@@ -3034,10 +2949,13 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { ++ dprintf("DEBUG2: (1) Flip: X=1 Y=0\n"); + yflip = 0; +- else ++ } else { ++ dprintf("DEBUG2: (1) Flip: X=1 Y=1\n"); + yflip = 1; ++ } + } + else if (cups->header.Duplex && + (!cups->header.Tumble && +@@ -3046,10 +2964,13 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 0; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { ++ dprintf("DEBUG2: (2) Flip: X=0 Y=1\n"); + yflip = 1; +- else ++ } else { ++ dprintf("DEBUG2: (2) Flip: X=0 Y=0\n"); + yflip = 0; ++ } + } + else if (cups->header.Duplex && + ((!cups->header.Tumble && +@@ -3061,13 +2982,17 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "True")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "True")) { ++ dprintf("DEBUG2: (3) Flip: X=1 Y=0\n"); + yflip = 0; +- else ++ } else { ++ dprintf("DEBUG2: (3) Flip: X=1 Y=1\n"); + yflip = 1; ++ } + } + else + { ++ dprintf("DEBUG2: (4) Flip: X=0 Y=0\n"); + xflip = 0; + yflip = 0; + } +@@ -3104,9 +3029,20 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif ++ /* We check whether all 4 margins match with the margin info ++ of the page size in the PPD. Here we check also for swapped ++ left/right and top/bottom margins as the cups->HWMargins ++ info can be from the previous page and there the margins ++ can be swapped due to duplex printing requirements */ + (!margins_set || +- (fabs(cups->HWMargins[0] - size->left) < 1.0 && +- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) ++ (((fabs(cups->HWMargins[0] - size->left) < 1.0 && ++ fabs(cups->HWMargins[2] - size->width + size->right) < 1.0) || ++ (fabs(cups->HWMargins[0] - size->width + size->right) < 1.0 && ++ fabs(cups->HWMargins[2] - size->left) < 1.0)) && ++ ((fabs(cups->HWMargins[1] - size->bottom) < 1.0 && ++ fabs(cups->HWMargins[3] - size->length + size->top) < 1.0) || ++ (fabs(cups->HWMargins[1] - size->length + size->top) < 1.0 && ++ fabs(cups->HWMargins[3] - size->bottom) < 1.0))))) + break; + + if (i > 0) +@@ -3148,9 +3084,20 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif ++ /* We check whether all 4 margins match with the margin info ++ of the page size in the PPD. Here we check also for swapped ++ left/right and top/bottom margins as the cups->HWMargins ++ info can be from the previous page and there the margins ++ can be swapped due to duplex printing requirements */ + (!margins_set || +- (fabs(cups->HWMargins[0] - size->left) < 1.0 && +- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) ++ (((fabs(cups->HWMargins[1] - size->left) < 1.0 && ++ fabs(cups->HWMargins[3] - size->width + size->right) < 1.0) || ++ (fabs(cups->HWMargins[1] - size->width + size->right) < 1.0 && ++ fabs(cups->HWMargins[3] - size->left) < 1.0)) && ++ ((fabs(cups->HWMargins[0] - size->bottom) < 1.0 && ++ fabs(cups->HWMargins[2] - size->length + size->top) < 1.0) || ++ (fabs(cups->HWMargins[0] - size->length + size->top) < 1.0 && ++ fabs(cups->HWMargins[2] - size->bottom) < 1.0))))) + break; + + if (i > 0) +@@ -3258,7 +3205,7 @@ cups_put_params(gx_device *pdev, /* + * Reallocate memory if the size or color depth was changed... + */ + +- if (color_set || size_set) ++ if (color_set || size_set || margins_set) + { + /* + * Make sure the page image is the correct size - current Ghostscript +@@ -3769,13 +3716,22 @@ cups_print_chunked(gx_device_printer *pd + unsigned char *srcptr, /* Pointer to data */ + *dstptr; /* Pointer to bits */ + int count; /* Count for loop */ +- int flip; /* Flip scanline? */ ++ int xflip, /* Flip scanline? */ ++ yflip, /* Reverse scanline order? */ ++ ystart, yend, ystep; /* Loop control for scanline order */ + ppd_attr_t *backside = NULL; + ++ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); ++ dprintf1("DEBUG2: cups->page = %d\n", cups->page); ++ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); ++ + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) ++ if (backside) { ++ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); + cupsPPD->flip_duplex = 0; ++ } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3785,19 +3741,36 @@ cups_print_chunked(gx_device_printer *pd + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- flip = 1; ++ xflip = 1; + else +- flip = 0; ++ xflip = 0; ++ if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && (!strcasecmp(backside->value, "Flipped") || ++ !strcasecmp(backside->value, "Rotated"))))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) { ++ yflip = 1; ++ ystart = cups->height - 1; ++ yend = -1; ++ ystep = -1; ++ } else { ++ yflip = 0; ++ ystart = 0; ++ yend = cups->height; ++ ystep = 1; ++ } + +- dprintf2("DEBUG: cups_print_chunked - flip = %d, height = %d\n", +- flip, cups->height); ++ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", ++ xflip, yflip, cups->height); + + /* + * Loop through the page bitmap and write chunked pixels, reversing as + * needed... + */ +- +- for (y = 0; y < cups->height; y ++) ++ for (y = ystart; y != yend; y += ystep) + { + /* + * Grab the scanline data... +@@ -3809,7 +3782,7 @@ cups_print_chunked(gx_device_printer *pd + gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); + } + +- if (flip) ++ if (xflip) + { + /* + * Flip the raster data before writing it... +@@ -3963,13 +3936,22 @@ cups_print_banded(gx_device_printer *pde + unsigned char *srcptr; /* Pointer to data */ + unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ + *kptr, *lcptr, *lmptr; /* ... */ +- int flip; /* Flip scanline? */ ++ int xflip, /* Flip scanline? */ ++ yflip, /* Reverse scanline order? */ ++ ystart, yend, ystep; /* Loop control for scanline order */ + ppd_attr_t *backside = NULL; + ++ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); ++ dprintf1("DEBUG2: cups->page = %d\n", cups->page); ++ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); ++ + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) ++ if (backside) { ++ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); + cupsPPD->flip_duplex = 0; ++ } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3979,12 +3961,30 @@ cups_print_banded(gx_device_printer *pde + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- flip = 1; ++ xflip = 1; + else +- flip = 0; ++ xflip = 0; ++ if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && (!strcasecmp(backside->value, "Flipped") || ++ !strcasecmp(backside->value, "Rotated"))))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) { ++ yflip = 1; ++ ystart = cups->height - 1; ++ yend = -1; ++ ystep = -1; ++ } else { ++ yflip = 0; ++ ystart = 0; ++ yend = cups->height; ++ ystep = 1; ++ } + +- dprintf2("DEBUG: cups_print_banded - flip = %d, height = %d\n", +- flip, cups->height); ++ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", ++ xflip, yflip, cups->height); + + /* + * Loop through the page bitmap and write banded pixels... We have +@@ -4001,7 +4001,7 @@ cups_print_banded(gx_device_printer *pde + bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; + #endif /* CUPS_RASTER_SYNCv1 */ + +- for (y = 0; y < cups->height; y ++) ++ for (y = ystart; y != yend; y += ystep) + { + /* + * Grab the scanline data... +@@ -4021,7 +4021,7 @@ cups_print_banded(gx_device_printer *pde + memset(dst, 0, cups->header.cupsBytesPerLine); + else + { +- if (flip) ++ if (xflip) + cptr = dst + bandbytes - 1; + else + cptr = dst; +@@ -4040,7 +4040,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4051,7 +4051,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *yptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4077,7 +4077,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *yptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4107,7 +4107,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_CMYK : + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4120,7 +4120,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *kptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4149,7 +4149,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *kptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4175,7 +4175,7 @@ cups_print_banded(gx_device_printer *pde + } + break; + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4198,7 +4198,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x01) + *lmptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4236,7 +4236,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4249,7 +4249,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 6; + +- if (flip) ++ if (xflip) + { + bit = 0x03; + cptr --; +@@ -4267,7 +4267,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 4; + +- if (flip) ++ if (xflip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4280,7 +4280,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 2; + +- if (flip) ++ if (xflip) + bit = 0x30; + else + bit = 0x03; +@@ -4293,7 +4293,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp; + +- if (flip) ++ if (xflip) + bit = 0x0c; + else + { +@@ -4313,7 +4313,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4328,7 +4328,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 6; + +- if (flip) ++ if (xflip) + { + bit = 0x03; + cptr --; +@@ -4349,7 +4349,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 4; + +- if (flip) ++ if (xflip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4364,7 +4364,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 2; + +- if (flip) ++ if (xflip) + bit = 0x30; + else + bit = 0x03; +@@ -4379,7 +4379,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp; + +- if (flip) ++ if (xflip) + bit = 0x0c; + else + { +@@ -4401,7 +4401,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4416,7 +4416,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (flip) ++ if (xflip) + { + cptr --; + mptr --; +@@ -4433,7 +4433,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!flip) ++ if (!xflip) + { + cptr ++; + mptr ++; +@@ -4450,7 +4450,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4467,7 +4467,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (flip) ++ if (xflip) + { + cptr --; + mptr --; +@@ -4487,7 +4487,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!flip) ++ if (!xflip) + { + cptr ++; + mptr ++; +@@ -4504,7 +4504,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4527,7 +4527,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4551,7 +4551,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --, srcptr += 6) + { + *cptr-- = srcptr[1]; +@@ -4580,7 +4580,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --, srcptr += 8) + { + *cptr-- = srcptr[1]; diff --git a/ghostscript.spec b/ghostscript.spec index 1e3bba6..fcf8f37 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 2%{?dist} +Release: 3%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -27,6 +27,7 @@ Patch8: ghostscript-jbig2dec-nullderef.patch Patch9: ghostscript-gs-executable.patch Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch +Patch12: ghostscript-gdevcups-y-axis.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -123,6 +124,10 @@ rm -rf libpng zlib jpeg jasper # Harden ghostscript's debugging output functions (bug #540760). %patch11 -p1 -b .vsnprintf +# Fixed gdevcups duplex output (bug #541604) by backporting upstream +# revision 10625. +%patch12 -p1 -b .gdevcups-y-axis + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -304,6 +309,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Thu Jan 21 2010 Tim Waugh 8.70-3 +- Fixed gdevcups duplex output (bug #541604) by backporting upstream + revision 10625. + * Thu Dec 24 2009 Tim Waugh 8.70-2 - Fix debugging output from gdevcups (CVE-2009-4270, bug #540760). - Harden ghostscript's debugging output functions (bug #540760). From 4a93f4fa871b86ab1d0388ade459dc743be9cfd9 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 22 Jan 2010 16:09:05 +0000 Subject: [PATCH 05/19] - New ghostscript-cups sub-package for some additional filters: pdftoraster; pstopxl. CUPS package still owns pstoraster for now. --- ghostscript-cups-filters.patch | 17 +++++++++++++++++ ghostscript.spec | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 ghostscript-cups-filters.patch diff --git a/ghostscript-cups-filters.patch b/ghostscript-cups-filters.patch new file mode 100644 index 0000000..ea6565d --- /dev/null +++ b/ghostscript-cups-filters.patch @@ -0,0 +1,17 @@ +diff -up ghostscript-8.70/cups/cups.mak.cups-filters ghostscript-8.70/cups/cups.mak +--- ghostscript-8.70/cups/cups.mak.cups-filters 2009-10-15 12:42:27.531402610 +0100 ++++ ghostscript-8.70/cups/cups.mak 2009-10-15 12:44:14.835402533 +0100 +@@ -63,10 +63,10 @@ install-cups: cups + $(INSTALL_PROGRAM) $(PDFTORASTER_XE) $(DESTDIR)$(CUPSSERVERBIN)/filter; \ + fi + $(INSTALL_PROGRAM) cups/pstopxl $(DESTDIR)$(CUPSSERVERBIN)/filter +- -mkdir -p $(DESTDIR)$(CUPSSERVERROOT) +- $(INSTALL_DATA) cups/pstoraster.convs $(DESTDIR)$(CUPSSERVERROOT) ++ -mkdir -p $(DESTDIR)$(CUPSDATA)/mime ++ $(INSTALL_DATA) cups/pstoraster.convs $(DESTDIR)$(CUPSDATA)/mime + if [ "$(CUPSPDFTORASTER)" = "1" ]; then \ +- $(INSTALL_DATA) cups/pdftoraster.convs $(DESTDIR)$(CUPSSERVERROOT); \ ++ $(INSTALL_DATA) cups/pdftoraster.convs $(DESTDIR)$(CUPSDATA)/mime; \ + fi + -mkdir -p $(DESTDIR)$(CUPSDATA)/model + $(INSTALL_DATA) cups/pxlcolor.ppd $(DESTDIR)$(CUPSDATA)/model diff --git a/ghostscript.spec b/ghostscript.spec index fcf8f37..e20cbfc 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 3%{?dist} +Release: 4%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -28,6 +28,7 @@ Patch9: ghostscript-gs-executable.patch Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch Patch12: ghostscript-gdevcups-y-axis.patch +Patch13: ghostscript-cups-filters.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -88,6 +89,15 @@ Group: Applications/Publishing %description gtk A GTK-enabled version of Ghostscript, called 'gsx'. +%package cups +Summary: CUPS filter for interpreting PostScript and PDF +Requires: %{name} = %{version}-%{release} +Requires: cups +Group: System Environment/Daemons + +%description cups +CUPS filter and conversion rules for interpreting PostScript and PDF. + %prep %setup -q -n %{name}-%{gs_ver} rm -rf libpng zlib jpeg jasper @@ -128,6 +138,9 @@ rm -rf libpng zlib jpeg jasper # revision 10625. %patch12 -p1 -b .gdevcups-y-axis +# Install CUPS filter convs files in the correct place. +%patch13 -p1 -b .cups-filters + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -297,6 +310,14 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %{_bindir}/gsx +%files cups +%defattr(-,root,root) +%{_datadir}/cups/model/pxl* +%{_datadir}/cups/mime/*.convs +# This really is /usr/lib, not _libdir -- it's more of a libexec usage +# but upstream CUPS won't use libexec. +/usr/lib/cups/filter/* + %files devel %defattr(-,root,root) %dir %{_includedir}/ghostscript @@ -309,6 +330,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Fri Jan 22 2010 Tim Waugh 8.70-4 +- New ghostscript-cups sub-package for some additional filters: + pdftoraster; pstopxl. CUPS package still owns pstoraster for now. + * Thu Jan 21 2010 Tim Waugh 8.70-3 - Fixed gdevcups duplex output (bug #541604) by backporting upstream revision 10625. From d7e1d637e59e9abc7d6f953f858590a0cd0c4323 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mon, 25 Jan 2010 10:32:46 +0000 Subject: [PATCH 06/19] - Fixed pdftoraster so that it waits for its sub-process to exit. - Another gdevcups duplex fix from upstream revision 10631 (bug #541604). --- ghostscript-gdevcups-y-axis.patch | 143 ++++++++++++++++------------- ghostscript-pdftoraster-exit.patch | 39 ++++++++ ghostscript.spec | 14 ++- 3 files changed, 126 insertions(+), 70 deletions(-) create mode 100644 ghostscript-pdftoraster-exit.patch diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch index 6e92ca1..39aafa9 100644 --- a/ghostscript-gdevcups-y-axis.patch +++ b/ghostscript-gdevcups-y-axis.patch @@ -1,6 +1,6 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/gdevcups.c ---- ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis 2010-01-21 11:17:55.974149011 +0000 -+++ ghostscript-8.70/cups/gdevcups.c 2010-01-21 11:18:54.823149257 +0000 +--- ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis 2010-01-25 08:34:15.197084192 +0000 ++++ ghostscript-8.70/cups/gdevcups.c 2010-01-25 08:34:21.603208913 +0000 @@ -605,8 +605,6 @@ private void cups_get_matrix(gx_device *pdev, /* I - Device info */ gs_matrix *pmat) /* O - Physical transform matrix */ @@ -141,7 +141,17 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; pmat->xy = 0.0; pmat->yx = 0.0; -@@ -2799,6 +2703,7 @@ cups_put_params(gx_device *pdev, /* +@@ -2792,13 +2696,16 @@ cups_put_params(gx_device *pdev, /* + int color_set; /* Were the color attrs set? */ + gdev_prn_space_params sp; /* Space parameter data */ + int width, /* New width of page */ +- height; /* New height of page */ ++ height; /* New height of page */ ++ static int width_old = 0, /* Previous width */ ++ height_old = 0; /* Previous height */ + ppd_attr_t *backside = NULL, + *backsiderequiresflippedmargins = NULL; + float swap; int xflip = 0, yflip = 0; int found = 0; @@ -149,32 +159,22 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); -@@ -2895,6 +2800,15 @@ cups_put_params(gx_device *pdev, /* - size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 || - param_read_float_array(plist, "PageSize", &arrayval) == 0; +@@ -2897,6 +2804,14 @@ cups_put_params(gx_device *pdev, /* margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; + color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || + param_read_int(plist, "cupsBitsPerColor", &intval) == 0; + /* We also recompute page size and margins if we simply get onto a new + page without necessarily having a page size change in the PostScript + code, as for some printers margins have to flipped on the back sides of + the sheets (even pages) when printing duplex */ + if (cups->page != lastpage) { + size_set = 1; -+ margins_set = 1; + lastpage = cups->page; + } - color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || - param_read_int(plist, "cupsBitsPerColor", &intval) == 0; -@@ -2995,7 +2909,7 @@ cups_put_params(gx_device *pdev, /* - * Update margins/sizes as needed... - */ - -- if (size_set) -+ if (size_set || margins_set) - { - /* - * Compute the page margins... -@@ -3011,6 +2925,7 @@ cups_put_params(gx_device *pdev, /* + stringoption(MediaClass, "MediaClass") + stringoption(MediaColor, "MediaColor") +@@ -3011,6 +2926,7 @@ cups_put_params(gx_device *pdev, /* if (cupsPPD != NULL) { dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); @@ -182,7 +182,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ dprintf1("DEBUG2: cups->page = %d\n", cups->page); dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -@@ -3034,10 +2949,13 @@ cups_put_params(gx_device *pdev, /* +@@ -3034,10 +2950,13 @@ cups_put_params(gx_device *pdev, /* { xflip = 1; if (backsiderequiresflippedmargins && @@ -198,7 +198,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ } else if (cups->header.Duplex && (!cups->header.Tumble && -@@ -3046,10 +2964,13 @@ cups_put_params(gx_device *pdev, /* +@@ -3046,10 +2965,13 @@ cups_put_params(gx_device *pdev, /* { xflip = 0; if (backsiderequiresflippedmargins && @@ -214,7 +214,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ } else if (cups->header.Duplex && ((!cups->header.Tumble && -@@ -3061,13 +2982,17 @@ cups_put_params(gx_device *pdev, /* +@@ -3061,13 +2983,17 @@ cups_put_params(gx_device *pdev, /* { xflip = 1; if (backsiderequiresflippedmargins && @@ -234,7 +234,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ xflip = 0; yflip = 0; } -@@ -3104,9 +3029,20 @@ cups_put_params(gx_device *pdev, /* +@@ -3104,9 +3030,20 @@ cups_put_params(gx_device *pdev, /* ((strlen(cups->header.cupsPageSizeName) == 0) || (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && #endif @@ -257,7 +257,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ break; if (i > 0) -@@ -3148,9 +3084,20 @@ cups_put_params(gx_device *pdev, /* +@@ -3148,9 +3085,20 @@ cups_put_params(gx_device *pdev, /* ((strlen(cups->header.cupsPageSizeName) == 0) || (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && #endif @@ -280,16 +280,27 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ break; if (i > 0) -@@ -3258,7 +3205,7 @@ cups_put_params(gx_device *pdev, /* - * Reallocate memory if the size or color depth was changed... - */ +@@ -3290,12 +3238,17 @@ cups_put_params(gx_device *pdev, /* -- if (color_set || size_set) -+ if (color_set || size_set || margins_set) - { /* - * Make sure the page image is the correct size - current Ghostscript -@@ -3769,13 +3716,22 @@ cups_print_chunked(gx_device_printer *pd + * Don't reallocate memory unless the device has been opened... ++ * Also reallocate only if the size has actually changed... + */ + +- if (pdev->is_open) ++ if (pdev->is_open && (width != width_old || height != height_old)) + { ++ ++ width_old = width; ++ height_old = height; ++ + /* +- * Device is open, so reallocate... ++ * Device is open and size has changed, so reallocate... + */ + + dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", +@@ -3769,13 +3722,22 @@ cups_print_chunked(gx_device_printer *pd unsigned char *srcptr, /* Pointer to data */ *dstptr; /* Pointer to bits */ int count; /* Count for loop */ @@ -314,7 +325,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ } if (cups->header.Duplex && cupsPPD && ((!cups->header.Tumble && -@@ -3785,19 +3741,36 @@ cups_print_chunked(gx_device_printer *pd +@@ -3785,19 +3747,36 @@ cups_print_chunked(gx_device_printer *pd (backside && (!strcasecmp(backside->value, "Flipped") || !strcasecmp(backside->value, "ManualTumble"))))) && !(cups->page & 1)) @@ -357,7 +368,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { /* * Grab the scanline data... -@@ -3809,7 +3782,7 @@ cups_print_chunked(gx_device_printer *pd +@@ -3809,7 +3788,7 @@ cups_print_chunked(gx_device_printer *pd gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); } @@ -366,7 +377,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { /* * Flip the raster data before writing it... -@@ -3963,13 +3936,22 @@ cups_print_banded(gx_device_printer *pde +@@ -3963,13 +3942,22 @@ cups_print_banded(gx_device_printer *pde unsigned char *srcptr; /* Pointer to data */ unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ *kptr, *lcptr, *lmptr; /* ... */ @@ -391,7 +402,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ } if (cups->header.Duplex && cupsPPD && ((!cups->header.Tumble && -@@ -3979,12 +3961,30 @@ cups_print_banded(gx_device_printer *pde +@@ -3979,12 +3967,30 @@ cups_print_banded(gx_device_printer *pde (backside && (!strcasecmp(backside->value, "Flipped") || !strcasecmp(backside->value, "ManualTumble"))))) && !(cups->page & 1)) @@ -426,7 +437,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ /* * Loop through the page bitmap and write banded pixels... We have -@@ -4001,7 +4001,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4001,7 +4007,7 @@ cups_print_banded(gx_device_printer *pde bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; #endif /* CUPS_RASTER_SYNCv1 */ @@ -435,7 +446,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { /* * Grab the scanline data... -@@ -4021,7 +4021,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4021,7 +4027,7 @@ cups_print_banded(gx_device_printer *pde memset(dst, 0, cups->header.cupsBytesPerLine); else { @@ -444,7 +455,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ cptr = dst + bandbytes - 1; else cptr = dst; -@@ -4040,7 +4040,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4040,7 +4046,7 @@ cups_print_banded(gx_device_printer *pde switch (cups->header.cupsColorSpace) { default : @@ -453,7 +464,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr ++) { -@@ -4051,7 +4051,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4051,7 +4057,7 @@ cups_print_banded(gx_device_printer *pde if (*srcptr & 0x10) *yptr |= bit; @@ -462,7 +473,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { if (bit < 128) bit <<= 1; -@@ -4077,7 +4077,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4077,7 +4083,7 @@ cups_print_banded(gx_device_printer *pde if (*srcptr & 0x1) *yptr |= bit; @@ -471,7 +482,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { if (bit < 128) bit <<= 1; -@@ -4107,7 +4107,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4107,7 +4113,7 @@ cups_print_banded(gx_device_printer *pde case CUPS_CSPACE_CMYK : case CUPS_CSPACE_YMCK : case CUPS_CSPACE_KCMY : @@ -480,7 +491,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr ++) { -@@ -4120,7 +4120,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4120,7 +4126,7 @@ cups_print_banded(gx_device_printer *pde if (*srcptr & 0x10) *kptr |= bit; @@ -489,7 +500,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { if (bit < 128) bit <<= 1; -@@ -4149,7 +4149,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4149,7 +4155,7 @@ cups_print_banded(gx_device_printer *pde if (*srcptr & 0x1) *kptr |= bit; @@ -498,7 +509,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { if (bit < 128) bit <<= 1; -@@ -4175,7 +4175,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4175,7 +4181,7 @@ cups_print_banded(gx_device_printer *pde } break; case CUPS_CSPACE_KCMYcm : @@ -507,7 +518,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr ++) { -@@ -4198,7 +4198,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4198,7 +4204,7 @@ cups_print_banded(gx_device_printer *pde if (*srcptr & 0x01) *lmptr |= bit; @@ -516,7 +527,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { if (bit < 128) bit <<= 1; -@@ -4236,7 +4236,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4236,7 +4242,7 @@ cups_print_banded(gx_device_printer *pde switch (cups->header.cupsColorSpace) { default : @@ -525,7 +536,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr ++) switch (bit) -@@ -4249,7 +4249,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4249,7 +4255,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *yptr |= temp << 6; @@ -534,7 +545,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { bit = 0x03; cptr --; -@@ -4267,7 +4267,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4267,7 +4273,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *yptr |= temp << 4; @@ -543,7 +554,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0xc0; else bit = 0x0c; -@@ -4280,7 +4280,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4280,7 +4286,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *yptr |= temp << 2; @@ -552,7 +563,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0x30; else bit = 0x03; -@@ -4293,7 +4293,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4293,7 +4299,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *yptr |= temp; @@ -561,7 +572,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0x0c; else { -@@ -4313,7 +4313,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4313,7 +4319,7 @@ cups_print_banded(gx_device_printer *pde case CUPS_CSPACE_YMCK : case CUPS_CSPACE_KCMY : case CUPS_CSPACE_KCMYcm : @@ -570,7 +581,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr ++) switch (bit) -@@ -4328,7 +4328,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4328,7 +4334,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *kptr |= temp << 6; @@ -579,7 +590,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { bit = 0x03; cptr --; -@@ -4349,7 +4349,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4349,7 +4355,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *kptr |= temp << 4; @@ -588,7 +599,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0xc0; else bit = 0x0c; -@@ -4364,7 +4364,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4364,7 +4370,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *kptr |= temp << 2; @@ -597,7 +608,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0x30; else bit = 0x03; -@@ -4379,7 +4379,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4379,7 +4385,7 @@ cups_print_banded(gx_device_printer *pde if ((temp = *srcptr & 0x03) != 0) *kptr |= temp; @@ -606,7 +617,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ bit = 0x0c; else { -@@ -4401,7 +4401,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4401,7 +4407,7 @@ cups_print_banded(gx_device_printer *pde switch (cups->header.cupsColorSpace) { default : @@ -615,7 +626,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr += 2) switch (bit) -@@ -4416,7 +4416,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4416,7 +4422,7 @@ cups_print_banded(gx_device_printer *pde bit = 0x0f; @@ -624,7 +635,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { cptr --; mptr --; -@@ -4433,7 +4433,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4433,7 +4439,7 @@ cups_print_banded(gx_device_printer *pde bit = 0xf0; @@ -633,7 +644,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { cptr ++; mptr ++; -@@ -4450,7 +4450,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4450,7 +4456,7 @@ cups_print_banded(gx_device_printer *pde case CUPS_CSPACE_YMCK : case CUPS_CSPACE_KCMY : case CUPS_CSPACE_KCMYcm : @@ -642,7 +653,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ x > 0; x --, srcptr += 2) switch (bit) -@@ -4467,7 +4467,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4467,7 +4473,7 @@ cups_print_banded(gx_device_printer *pde bit = 0x0f; @@ -651,7 +662,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { cptr --; mptr --; -@@ -4487,7 +4487,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4487,7 +4493,7 @@ cups_print_banded(gx_device_printer *pde bit = 0xf0; @@ -660,7 +671,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ { cptr ++; mptr ++; -@@ -4504,7 +4504,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4504,7 +4510,7 @@ cups_print_banded(gx_device_printer *pde switch (cups->header.cupsColorSpace) { default : @@ -669,7 +680,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ for (x = cups->width; x > 0; x --) { *cptr-- = *srcptr++; -@@ -4527,7 +4527,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4527,7 +4533,7 @@ cups_print_banded(gx_device_printer *pde case CUPS_CSPACE_YMCK : case CUPS_CSPACE_KCMY : case CUPS_CSPACE_KCMYcm : @@ -678,7 +689,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ for (x = cups->width; x > 0; x --) { *cptr-- = *srcptr++; -@@ -4551,7 +4551,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4551,7 +4557,7 @@ cups_print_banded(gx_device_printer *pde switch (cups->header.cupsColorSpace) { default : @@ -687,7 +698,7 @@ diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/ for (x = cups->width; x > 0; x --, srcptr += 6) { *cptr-- = srcptr[1]; -@@ -4580,7 +4580,7 @@ cups_print_banded(gx_device_printer *pde +@@ -4580,7 +4586,7 @@ cups_print_banded(gx_device_printer *pde case CUPS_CSPACE_YMCK : case CUPS_CSPACE_KCMY : case CUPS_CSPACE_KCMYcm : diff --git a/ghostscript-pdftoraster-exit.patch b/ghostscript-pdftoraster-exit.patch new file mode 100644 index 0000000..89feeab --- /dev/null +++ b/ghostscript-pdftoraster-exit.patch @@ -0,0 +1,39 @@ +diff -up ghostscript-8.70/cups/pdftoraster.c.pdftoraster-exit ghostscript-8.70/cups/pdftoraster.c +--- ghostscript-8.70/cups/pdftoraster.c.pdftoraster-exit 2008-10-17 23:58:21.000000000 +0100 ++++ ghostscript-8.70/cups/pdftoraster.c 2010-01-25 10:15:42.269209639 +0000 +@@ -35,6 +35,8 @@ MIT Open Source License - http://www.o + #include + #include + #include ++#include ++#include + + #define MAX_CHECK_COMMENT_LINES 20 + #ifndef GS +@@ -123,6 +125,7 @@ int main(int argc, char *argv[], char *e + const char* apos; + int fds[2]; + int pid; ++ int status; + + parseOpts(argc, argv); + +@@ -502,8 +505,17 @@ int main(int argc, char *argv[], char *e + } + } + fclose(fp); ++ close (fds[1]); + } + +- exit(0); ++ if (waitpid (pid, &status, 0) == -1) { ++ perror (GS); ++ exit (1); ++ } ++ ++ if (WIFEXITED (status)) ++ exit(WEXITSTATUS (status)); ++ else ++ exit(1); + } + diff --git a/ghostscript.spec b/ghostscript.spec index e20cbfc..1490c24 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 4%{?dist} +Release: 5%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -29,6 +29,7 @@ Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch Patch12: ghostscript-gdevcups-y-axis.patch Patch13: ghostscript-cups-filters.patch +Patch14: ghostscript-pdftoraster-exit.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -141,6 +142,9 @@ rm -rf libpng zlib jpeg jasper # Install CUPS filter convs files in the correct place. %patch13 -p1 -b .cups-filters +# Fixed pdftoraster so that it waits for its sub-process to exit. +%patch14 -p1 -b .pdftoraster-exit + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -296,10 +300,7 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libijs-*.so* %dir %{_libdir}/%{name} %{_libdir}/%{name}/%{gs_dot_ver} -/usr/lib/cups/filter/pstopxl -%{_datadir}/cups/model/pxl* %config(noreplace) /etc/ghostscript/%{gs_dot_ver}/* -/usr/lib/cups/filter/pdftoraster %files doc %defattr(-,root,root) @@ -330,6 +331,11 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Mon Jan 25 2010 Tim Waugh 8.70-5 +- Fixed pdftoraster so that it waits for its sub-process to exit. +- Another gdevcups duplex fix from upstream revision 10631 + (bug #541604). + * Fri Jan 22 2010 Tim Waugh 8.70-4 - New ghostscript-cups sub-package for some additional filters: pdftoraster; pstopxl. CUPS package still owns pstoraster for now. From e6806838712aacd07b5dc87a22516aa2e54d3350 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Tue, 16 Feb 2010 12:30:51 +0000 Subject: [PATCH 07/19] - Reverted gdevcups duplex changes as they cause a regression (see bug #563313). --- ghostscript-gdevcups-y-axis.patch | 709 ------------------------------ ghostscript.spec | 19 +- 2 files changed, 9 insertions(+), 719 deletions(-) delete mode 100644 ghostscript-gdevcups-y-axis.patch diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch deleted file mode 100644 index 39aafa9..0000000 --- a/ghostscript-gdevcups-y-axis.patch +++ /dev/null @@ -1,709 +0,0 @@ -diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/gdevcups.c ---- ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis 2010-01-25 08:34:15.197084192 +0000 -+++ ghostscript-8.70/cups/gdevcups.c 2010-01-25 08:34:21.603208913 +0000 -@@ -605,8 +605,6 @@ private void - cups_get_matrix(gx_device *pdev, /* I - Device info */ - gs_matrix *pmat) /* O - Physical transform matrix */ - { -- ppd_attr_t *backside = NULL; -- - dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat); - - /* -@@ -620,119 +618,25 @@ cups_get_matrix(gx_device *pdev, /* I - - * Set the transform matrix... - */ - -- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -- dprintf1("DEBUG2: cups->page = %d\n", cups->page); -- -- if (cupsPPD) -- { -- backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -- if (backside) { -- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); -- cupsPPD->flip_duplex = 0; -- } -- dprintf1("DEBUG2: cupsPPD->flip_duplex = %d\n", cupsPPD->flip_duplex); -- } -- - if (cups->landscape) - { - /* - * Do landscape orientation... - */ -- -- if (cups->header.Duplex && cupsPPD && -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "Flipped"))) && -- !(cups->page & 1)) -- { -- pmat->xx = 0.0; -- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->yy = 0.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; -- } -- else if (cups->header.Duplex && cupsPPD && -- (!cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "Flipped"))) && -- !(cups->page & 1)) -- { -- pmat->xx = 0.0; -- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; -- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->yy = 0.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -- pmat->ty = (float)cups->header.HWResolution[1] * -- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; -- } -- else if (cups->header.Duplex && cupsPPD && -- ((!cups->header.Tumble && -- (cupsPPD->flip_duplex || -- (backside && !strcasecmp(backside->value, "Rotated")))) || -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "ManualTumble")))) && -- !(cups->page & 1)) -- { -- pmat->xx = 0.0; -- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; -- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->yy = 0.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -- pmat->ty = (float)cups->header.HWResolution[1] * -- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; -- } -- else -- { -- pmat->xx = 0.0; -- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->yy = 0.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; -- } -- } -- else if (cups->header.Duplex && cupsPPD && -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "Flipped"))) && -- !(cups->page & 1)) -- { -- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->xy = 0.0; -- pmat->yx = 0.0; -- pmat->yy = -(float)cups->header.HWResolution[1] / 72.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -- pmat->ty = (float)cups->header.HWResolution[1] * -- ((float)cups->header.PageSize[1] - pdev->HWMargins[3]) / 72.0; -- } -- else if (cups->header.Duplex && cupsPPD && -- (!cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "Flipped"))) && -- !(cups->page & 1)) -- { -- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->xy = 0.0; -- pmat->yx = 0.0; -- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; -- } -- else if (cups->header.Duplex && cupsPPD && -- ((!cups->header.Tumble && -- (cupsPPD->flip_duplex || -- (backside && !strcasecmp(backside->value, "Rotated")))) || -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "ManualTumble")))) && -- !(cups->page & 1)) -- { -- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->xy = 0.0; -- pmat->yx = 0.0; -- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; -+ dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n"); -+ pmat->xx = 0.0; -+ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -+ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->yy = 0.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -+ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; - } - else - { -+ /* -+ * Do portrait orientation... -+ */ -+ dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n"); - pmat->xx = (float)cups->header.HWResolution[0] / 72.0; - pmat->xy = 0.0; - pmat->yx = 0.0; -@@ -2792,13 +2696,16 @@ cups_put_params(gx_device *pdev, /* - int color_set; /* Were the color attrs set? */ - gdev_prn_space_params sp; /* Space parameter data */ - int width, /* New width of page */ -- height; /* New height of page */ -+ height; /* New height of page */ -+ static int width_old = 0, /* Previous width */ -+ height_old = 0; /* Previous height */ - ppd_attr_t *backside = NULL, - *backsiderequiresflippedmargins = NULL; - float swap; - int xflip = 0, - yflip = 0; - int found = 0; -+ static int lastpage = 0; - - dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); - -@@ -2897,6 +2804,14 @@ cups_put_params(gx_device *pdev, /* - margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; - color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || - param_read_int(plist, "cupsBitsPerColor", &intval) == 0; -+ /* We also recompute page size and margins if we simply get onto a new -+ page without necessarily having a page size change in the PostScript -+ code, as for some printers margins have to flipped on the back sides of -+ the sheets (even pages) when printing duplex */ -+ if (cups->page != lastpage) { -+ size_set = 1; -+ lastpage = cups->page; -+ } - - stringoption(MediaClass, "MediaClass") - stringoption(MediaColor, "MediaColor") -@@ -3011,6 +2926,7 @@ cups_put_params(gx_device *pdev, /* - if (cupsPPD != NULL) - { - dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -+ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); - dprintf1("DEBUG2: cups->page = %d\n", cups->page); - dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); - -@@ -3034,10 +2950,13 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 1; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "False")) -+ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { -+ dprintf("DEBUG2: (1) Flip: X=1 Y=0\n"); - yflip = 0; -- else -+ } else { -+ dprintf("DEBUG2: (1) Flip: X=1 Y=1\n"); - yflip = 1; -+ } - } - else if (cups->header.Duplex && - (!cups->header.Tumble && -@@ -3046,10 +2965,13 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 0; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "False")) -+ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { -+ dprintf("DEBUG2: (2) Flip: X=0 Y=1\n"); - yflip = 1; -- else -+ } else { -+ dprintf("DEBUG2: (2) Flip: X=0 Y=0\n"); - yflip = 0; -+ } - } - else if (cups->header.Duplex && - ((!cups->header.Tumble && -@@ -3061,13 +2983,17 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 1; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "True")) -+ !strcasecmp(backsiderequiresflippedmargins->value, "True")) { -+ dprintf("DEBUG2: (3) Flip: X=1 Y=0\n"); - yflip = 0; -- else -+ } else { -+ dprintf("DEBUG2: (3) Flip: X=1 Y=1\n"); - yflip = 1; -+ } - } - else - { -+ dprintf("DEBUG2: (4) Flip: X=0 Y=0\n"); - xflip = 0; - yflip = 0; - } -@@ -3104,9 +3030,20 @@ cups_put_params(gx_device *pdev, /* - ((strlen(cups->header.cupsPageSizeName) == 0) || - (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && - #endif -+ /* We check whether all 4 margins match with the margin info -+ of the page size in the PPD. Here we check also for swapped -+ left/right and top/bottom margins as the cups->HWMargins -+ info can be from the previous page and there the margins -+ can be swapped due to duplex printing requirements */ - (!margins_set || -- (fabs(cups->HWMargins[0] - size->left) < 1.0 && -- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) -+ (((fabs(cups->HWMargins[0] - size->left) < 1.0 && -+ fabs(cups->HWMargins[2] - size->width + size->right) < 1.0) || -+ (fabs(cups->HWMargins[0] - size->width + size->right) < 1.0 && -+ fabs(cups->HWMargins[2] - size->left) < 1.0)) && -+ ((fabs(cups->HWMargins[1] - size->bottom) < 1.0 && -+ fabs(cups->HWMargins[3] - size->length + size->top) < 1.0) || -+ (fabs(cups->HWMargins[1] - size->length + size->top) < 1.0 && -+ fabs(cups->HWMargins[3] - size->bottom) < 1.0))))) - break; - - if (i > 0) -@@ -3148,9 +3085,20 @@ cups_put_params(gx_device *pdev, /* - ((strlen(cups->header.cupsPageSizeName) == 0) || - (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && - #endif -+ /* We check whether all 4 margins match with the margin info -+ of the page size in the PPD. Here we check also for swapped -+ left/right and top/bottom margins as the cups->HWMargins -+ info can be from the previous page and there the margins -+ can be swapped due to duplex printing requirements */ - (!margins_set || -- (fabs(cups->HWMargins[0] - size->left) < 1.0 && -- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) -+ (((fabs(cups->HWMargins[1] - size->left) < 1.0 && -+ fabs(cups->HWMargins[3] - size->width + size->right) < 1.0) || -+ (fabs(cups->HWMargins[1] - size->width + size->right) < 1.0 && -+ fabs(cups->HWMargins[3] - size->left) < 1.0)) && -+ ((fabs(cups->HWMargins[0] - size->bottom) < 1.0 && -+ fabs(cups->HWMargins[2] - size->length + size->top) < 1.0) || -+ (fabs(cups->HWMargins[0] - size->length + size->top) < 1.0 && -+ fabs(cups->HWMargins[2] - size->bottom) < 1.0))))) - break; - - if (i > 0) -@@ -3290,12 +3238,17 @@ cups_put_params(gx_device *pdev, /* - - /* - * Don't reallocate memory unless the device has been opened... -+ * Also reallocate only if the size has actually changed... - */ - -- if (pdev->is_open) -+ if (pdev->is_open && (width != width_old || height != height_old)) - { -+ -+ width_old = width; -+ height_old = height; -+ - /* -- * Device is open, so reallocate... -+ * Device is open and size has changed, so reallocate... - */ - - dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", -@@ -3769,13 +3722,22 @@ cups_print_chunked(gx_device_printer *pd - unsigned char *srcptr, /* Pointer to data */ - *dstptr; /* Pointer to bits */ - int count; /* Count for loop */ -- int flip; /* Flip scanline? */ -+ int xflip, /* Flip scanline? */ -+ yflip, /* Reverse scanline order? */ -+ ystart, yend, ystep; /* Loop control for scanline order */ - ppd_attr_t *backside = NULL; - -+ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -+ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); -+ dprintf1("DEBUG2: cups->page = %d\n", cups->page); -+ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -+ - if (cupsPPD) { - backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -- if (backside) -+ if (backside) { -+ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); - cupsPPD->flip_duplex = 0; -+ } - } - if (cups->header.Duplex && cupsPPD && - ((!cups->header.Tumble && -@@ -3785,19 +3747,36 @@ cups_print_chunked(gx_device_printer *pd - (backside && (!strcasecmp(backside->value, "Flipped") || - !strcasecmp(backside->value, "ManualTumble"))))) && - !(cups->page & 1)) -- flip = 1; -+ xflip = 1; - else -- flip = 0; -+ xflip = 0; -+ if (cups->header.Duplex && cupsPPD && -+ ((!cups->header.Tumble && -+ (cupsPPD->flip_duplex || -+ (backside && (!strcasecmp(backside->value, "Flipped") || -+ !strcasecmp(backside->value, "Rotated"))))) || -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "ManualTumble")))) && -+ !(cups->page & 1)) { -+ yflip = 1; -+ ystart = cups->height - 1; -+ yend = -1; -+ ystep = -1; -+ } else { -+ yflip = 0; -+ ystart = 0; -+ yend = cups->height; -+ ystep = 1; -+ } - -- dprintf2("DEBUG: cups_print_chunked - flip = %d, height = %d\n", -- flip, cups->height); -+ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", -+ xflip, yflip, cups->height); - - /* - * Loop through the page bitmap and write chunked pixels, reversing as - * needed... - */ -- -- for (y = 0; y < cups->height; y ++) -+ for (y = ystart; y != yend; y += ystep) - { - /* - * Grab the scanline data... -@@ -3809,7 +3788,7 @@ cups_print_chunked(gx_device_printer *pd - gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); - } - -- if (flip) -+ if (xflip) - { - /* - * Flip the raster data before writing it... -@@ -3963,13 +3942,22 @@ cups_print_banded(gx_device_printer *pde - unsigned char *srcptr; /* Pointer to data */ - unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ - *kptr, *lcptr, *lmptr; /* ... */ -- int flip; /* Flip scanline? */ -+ int xflip, /* Flip scanline? */ -+ yflip, /* Reverse scanline order? */ -+ ystart, yend, ystep; /* Loop control for scanline order */ - ppd_attr_t *backside = NULL; - -+ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -+ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); -+ dprintf1("DEBUG2: cups->page = %d\n", cups->page); -+ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -+ - if (cupsPPD) { - backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -- if (backside) -+ if (backside) { -+ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); - cupsPPD->flip_duplex = 0; -+ } - } - if (cups->header.Duplex && cupsPPD && - ((!cups->header.Tumble && -@@ -3979,12 +3967,30 @@ cups_print_banded(gx_device_printer *pde - (backside && (!strcasecmp(backside->value, "Flipped") || - !strcasecmp(backside->value, "ManualTumble"))))) && - !(cups->page & 1)) -- flip = 1; -+ xflip = 1; - else -- flip = 0; -+ xflip = 0; -+ if (cups->header.Duplex && cupsPPD && -+ ((!cups->header.Tumble && -+ (cupsPPD->flip_duplex || -+ (backside && (!strcasecmp(backside->value, "Flipped") || -+ !strcasecmp(backside->value, "Rotated"))))) || -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "ManualTumble")))) && -+ !(cups->page & 1)) { -+ yflip = 1; -+ ystart = cups->height - 1; -+ yend = -1; -+ ystep = -1; -+ } else { -+ yflip = 0; -+ ystart = 0; -+ yend = cups->height; -+ ystep = 1; -+ } - -- dprintf2("DEBUG: cups_print_banded - flip = %d, height = %d\n", -- flip, cups->height); -+ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", -+ xflip, yflip, cups->height); - - /* - * Loop through the page bitmap and write banded pixels... We have -@@ -4001,7 +4007,7 @@ cups_print_banded(gx_device_printer *pde - bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; - #endif /* CUPS_RASTER_SYNCv1 */ - -- for (y = 0; y < cups->height; y ++) -+ for (y = ystart; y != yend; y += ystep) - { - /* - * Grab the scanline data... -@@ -4021,7 +4027,7 @@ cups_print_banded(gx_device_printer *pde - memset(dst, 0, cups->header.cupsBytesPerLine); - else - { -- if (flip) -+ if (xflip) - cptr = dst + bandbytes - 1; - else - cptr = dst; -@@ -4040,7 +4046,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4051,7 +4057,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x10) - *yptr |= bit; - -- if (flip) -+ if (xflip) - { - if (bit < 128) - bit <<= 1; -@@ -4077,7 +4083,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x1) - *yptr |= bit; - -- if (flip) -+ if (xflip) - { - if (bit < 128) - bit <<= 1; -@@ -4107,7 +4113,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_CMYK : - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : -- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4120,7 +4126,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x10) - *kptr |= bit; - -- if (flip) -+ if (xflip) - { - if (bit < 128) - bit <<= 1; -@@ -4149,7 +4155,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x1) - *kptr |= bit; - -- if (flip) -+ if (xflip) - { - if (bit < 128) - bit <<= 1; -@@ -4175,7 +4181,7 @@ cups_print_banded(gx_device_printer *pde - } - break; - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4198,7 +4204,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x01) - *lmptr |= bit; - -- if (flip) -+ if (xflip) - { - if (bit < 128) - bit <<= 1; -@@ -4236,7 +4242,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; -+ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; - x > 0; - x --, srcptr ++) - switch (bit) -@@ -4249,7 +4255,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 6; - -- if (flip) -+ if (xflip) - { - bit = 0x03; - cptr --; -@@ -4267,7 +4273,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 4; - -- if (flip) -+ if (xflip) - bit = 0xc0; - else - bit = 0x0c; -@@ -4280,7 +4286,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 2; - -- if (flip) -+ if (xflip) - bit = 0x30; - else - bit = 0x03; -@@ -4293,7 +4299,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp; - -- if (flip) -+ if (xflip) - bit = 0x0c; - else - { -@@ -4313,7 +4319,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; -+ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; - x > 0; - x --, srcptr ++) - switch (bit) -@@ -4328,7 +4334,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 6; - -- if (flip) -+ if (xflip) - { - bit = 0x03; - cptr --; -@@ -4349,7 +4355,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 4; - -- if (flip) -+ if (xflip) - bit = 0xc0; - else - bit = 0x0c; -@@ -4364,7 +4370,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 2; - -- if (flip) -+ if (xflip) - bit = 0x30; - else - bit = 0x03; -@@ -4379,7 +4385,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp; - -- if (flip) -+ if (xflip) - bit = 0x0c; - else - { -@@ -4401,7 +4407,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; -+ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; - x > 0; - x --, srcptr += 2) - switch (bit) -@@ -4416,7 +4422,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0x0f; - -- if (flip) -+ if (xflip) - { - cptr --; - mptr --; -@@ -4433,7 +4439,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0xf0; - -- if (!flip) -+ if (!xflip) - { - cptr ++; - mptr ++; -@@ -4450,7 +4456,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; -+ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; - x > 0; - x --, srcptr += 2) - switch (bit) -@@ -4467,7 +4473,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0x0f; - -- if (flip) -+ if (xflip) - { - cptr --; - mptr --; -@@ -4487,7 +4493,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0xf0; - -- if (!flip) -+ if (!xflip) - { - cptr ++; - mptr ++; -@@ -4504,7 +4510,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- if (flip) -+ if (xflip) - for (x = cups->width; x > 0; x --) - { - *cptr-- = *srcptr++; -@@ -4527,7 +4533,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- if (flip) -+ if (xflip) - for (x = cups->width; x > 0; x --) - { - *cptr-- = *srcptr++; -@@ -4551,7 +4557,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- if (flip) -+ if (xflip) - for (x = cups->width; x > 0; x --, srcptr += 6) - { - *cptr-- = srcptr[1]; -@@ -4580,7 +4586,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- if (flip) -+ if (xflip) - for (x = cups->width; x > 0; x --, srcptr += 8) - { - *cptr-- = srcptr[1]; diff --git a/ghostscript.spec b/ghostscript.spec index 1490c24..3845831 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 5%{?dist} +Release: 6%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -27,9 +27,8 @@ Patch8: ghostscript-jbig2dec-nullderef.patch Patch9: ghostscript-gs-executable.patch Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch -Patch12: ghostscript-gdevcups-y-axis.patch -Patch13: ghostscript-cups-filters.patch -Patch14: ghostscript-pdftoraster-exit.patch +Patch12: ghostscript-cups-filters.patch +Patch13: ghostscript-pdftoraster-exit.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -135,15 +134,11 @@ rm -rf libpng zlib jpeg jasper # Harden ghostscript's debugging output functions (bug #540760). %patch11 -p1 -b .vsnprintf -# Fixed gdevcups duplex output (bug #541604) by backporting upstream -# revision 10625. -%patch12 -p1 -b .gdevcups-y-axis - # Install CUPS filter convs files in the correct place. -%patch13 -p1 -b .cups-filters +%patch12 -p1 -b .cups-filters # Fixed pdftoraster so that it waits for its sub-process to exit. -%patch14 -p1 -b .pdftoraster-exit +%patch13 -p1 -b .pdftoraster-exit # Convert manual pages to UTF-8 from8859_1() { @@ -331,6 +326,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Tue Feb 16 2010 Tim Waugh 8.70-6 +- Reverted gdevcups duplex changes as they cause a regression + (see bug #563313). + * Mon Jan 25 2010 Tim Waugh 8.70-5 - Fixed pdftoraster so that it waits for its sub-process to exit. - Another gdevcups duplex fix from upstream revision 10631 From e9e47e765b245f3c80686aaab21f4ba5d2b1a720 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Wed, 17 Feb 2010 17:53:03 +0000 Subject: [PATCH 08/19] - Reverted gdevcups duplex changes as they cause a regression (see bug #563313). --- .cvsignore | 1 + ghostscript-jbig2dec-nullderef.patch | 43 ++----------------------- ghostscript-vsnprintf.patch | 48 ++++++---------------------- ghostscript.spec | 11 ++++--- sources | 2 +- 5 files changed, 22 insertions(+), 83 deletions(-) diff --git a/.cvsignore b/.cvsignore index ce33728..7eb946d 100644 --- a/.cvsignore +++ b/.cvsignore @@ -25,3 +25,4 @@ ghostscript-8.62.tar.bz2 ghostscript-8.63.tar.bz2 ghostscript-8.64.tar.bz2 ghostscript-8.70.tar.xz +ghostscript-8.71.tar.xz diff --git a/ghostscript-jbig2dec-nullderef.patch b/ghostscript-jbig2dec-nullderef.patch index bd351aa..1dd4be4 100644 --- a/ghostscript-jbig2dec-nullderef.patch +++ b/ghostscript-jbig2dec-nullderef.patch @@ -1,20 +1,6 @@ -diff -up ghostscript-8.70/jbig2dec/jbig2_generic.c.jbig2dec-nullderef ghostscript-8.70/jbig2dec/jbig2_generic.c ---- ghostscript-8.70/jbig2dec/jbig2_generic.c.jbig2dec-nullderef 2009-05-29 07:48:44.000000000 +0100 -+++ ghostscript-8.70/jbig2dec/jbig2_generic.c 2009-08-03 17:51:13.864875636 +0100 -@@ -596,6 +596,10 @@ jbig2_immediate_generic_region(Jbig2Ctx - memcpy (params.gbat, gbat, gbat_bytes); - - image = jbig2_image_new(ctx, rsi.width, rsi.height); -+ if (image == NULL) -+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, -+ "failed to allocate buffer for image"); -+ - jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, - "allocated %d x %d image buffer for region decode results", - rsi.width, rsi.height); -diff -up ghostscript-8.70/jbig2dec/jbig2_symbol_dict.c.jbig2dec-nullderef ghostscript-8.70/jbig2dec/jbig2_symbol_dict.c ---- ghostscript-8.70/jbig2dec/jbig2_symbol_dict.c.jbig2dec-nullderef 2009-05-29 07:48:44.000000000 +0100 -+++ ghostscript-8.70/jbig2dec/jbig2_symbol_dict.c 2009-08-03 17:52:35.318750131 +0100 +diff -up ghostscript-8.71/jbig2dec/jbig2_symbol_dict.c.jbig2dec-nullderef ghostscript-8.71/jbig2dec/jbig2_symbol_dict.c +--- ghostscript-8.71/jbig2dec/jbig2_symbol_dict.c.jbig2dec-nullderef 2009-05-29 07:48:44.000000000 +0100 ++++ ghostscript-8.71/jbig2dec/jbig2_symbol_dict.c 2010-02-17 12:06:42.040614797 +0000 @@ -367,6 +367,11 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx, memcpy(region_params.gbat, params->sdat, sdat_bytes); @@ -56,26 +42,3 @@ diff -up ghostscript-8.70/jbig2dec/jbig2_symbol_dict.c.jbig2dec-nullderef ghosts jbig2_image_compose(ctx, glyph, image, -x, 0, JBIG2_COMPOSE_REPLACE); x += SDNEWSYMWIDTHS[j]; -diff -up ghostscript-8.70/jbig2dec/jbig2_text.c.jbig2dec-nullderef ghostscript-8.70/jbig2dec/jbig2_text.c ---- ghostscript-8.70/jbig2dec/jbig2_text.c.jbig2dec-nullderef 2009-05-29 07:48:44.000000000 +0100 -+++ ghostscript-8.70/jbig2dec/jbig2_text.c 2009-08-03 17:53:05.166750610 +0100 -@@ -312,6 +312,9 @@ jbig2_decode_text_region(Jbig2Ctx *ctx, - IBO = IB; - refimage = jbig2_image_new(ctx, IBO->width + RDW, - IBO->height + RDH); -+ if (image == NULL) -+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, -+ "could not allocate image storage"); - - /* Table 12 */ - rparams.GRTEMPLATE = params->SBRTEMPLATE; -@@ -676,6 +679,9 @@ jbig2_parse_text_region(Jbig2Ctx *ctx, J - } - - image = jbig2_image_new(ctx, region_info.width, region_info.height); -+ if (image == NULL) -+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, -+ "unable to allocate image storage"); - - ws = jbig2_word_stream_buf_new(ctx, segment_data + offset, segment->data_length - offset); - if (!params.SBHUFF) { diff --git a/ghostscript-vsnprintf.patch b/ghostscript-vsnprintf.patch index a7fac21..6effbc1 100644 --- a/ghostscript-vsnprintf.patch +++ b/ghostscript-vsnprintf.patch @@ -1,35 +1,7 @@ -diff -up ghostscript-8.70/base/gsmisc.c.vsnprintf ghostscript-8.70/base/gsmisc.c ---- ghostscript-8.70/base/gsmisc.c.vsnprintf 2008-01-07 18:43:02.000000000 +0000 -+++ ghostscript-8.70/base/gsmisc.c 2009-11-24 17:16:38.575250571 +0000 -@@ -69,10 +69,10 @@ int outprintf(const gs_memory_t *mem, co - - va_start(args, fmt); - -- count = vsprintf(buf, fmt, args); -+ count = vsnprintf(buf, sizeof (buf), fmt, args); - outwrite(mem, buf, count); -- if (count >= PRINTF_BUF_LENGTH) { -- count = sprintf(buf, -+ if (count == -1 || count >= sizeof (buf)) { -+ count = snprintf(buf, sizeof (buf), - "PANIC: printf exceeded %d bytes. Stack has been corrupted.\n", - PRINTF_BUF_LENGTH); - outwrite(mem, buf, count); -@@ -89,10 +89,10 @@ int errprintf(const char *fmt, ...) - - va_start(args, fmt); - -- count = vsprintf(buf, fmt, args); -+ count = vsnprintf(buf, sizeof (buf), fmt, args); - errwrite(buf, count); -- if (count >= PRINTF_BUF_LENGTH) { -- count = sprintf(buf, -+ if (count == -1 || count >= sizeof (buf)) { -+ count = snprintf(buf, sizeof (buf), - "PANIC: printf exceeded %d bytes. Stack has been corrupted.\n", - PRINTF_BUF_LENGTH); - errwrite(buf, count); -@@ -236,7 +236,7 @@ int gs_throw_imp(const char *func, const +diff -up ghostscript-8.71/base/gsmisc.c.vsnprintf ghostscript-8.71/base/gsmisc.c +--- ghostscript-8.71/base/gsmisc.c.vsnprintf 2010-01-05 00:52:07.000000000 +0000 ++++ ghostscript-8.71/base/gsmisc.c 2010-02-17 11:30:13.777615156 +0000 +@@ -235,7 +235,7 @@ int gs_throw_imp(const char *func, const va_list ap; va_start(ap, fmt); @@ -38,9 +10,9 @@ diff -up ghostscript-8.70/base/gsmisc.c.vsnprintf ghostscript-8.70/base/gsmisc.c msg[sizeof(msg) - 1] = 0; va_end(ap); -diff -up ghostscript-8.70/base/gxttfb.c.vsnprintf ghostscript-8.70/base/gxttfb.c ---- ghostscript-8.70/base/gxttfb.c.vsnprintf 2009-07-09 06:59:44.000000000 +0100 -+++ ghostscript-8.70/base/gxttfb.c 2009-11-24 17:16:38.577250996 +0000 +diff -up ghostscript-8.71/base/gxttfb.c.vsnprintf ghostscript-8.71/base/gxttfb.c +--- ghostscript-8.71/base/gxttfb.c.vsnprintf 2009-12-06 19:12:08.000000000 +0000 ++++ ghostscript-8.71/base/gxttfb.c 2010-02-17 11:30:13.778616076 +0000 @@ -246,7 +246,7 @@ static int DebugPrint(ttfFont *ttf, cons if (gs_debug_c('Y')) { @@ -50,9 +22,9 @@ diff -up ghostscript-8.70/base/gxttfb.c.vsnprintf ghostscript-8.70/base/gxttfb.c /* NB: moved debug output from stdout to stderr */ errwrite(buf, count); -diff -up ghostscript-8.70/base/rinkj/rinkj-byte-stream.c.vsnprintf ghostscript-8.70/base/rinkj/rinkj-byte-stream.c ---- ghostscript-8.70/base/rinkj/rinkj-byte-stream.c.vsnprintf 2008-04-04 02:02:16.000000000 +0100 -+++ ghostscript-8.70/base/rinkj/rinkj-byte-stream.c 2009-11-24 17:16:38.577250996 +0000 +diff -up ghostscript-8.71/base/rinkj/rinkj-byte-stream.c.vsnprintf ghostscript-8.71/base/rinkj/rinkj-byte-stream.c +--- ghostscript-8.71/base/rinkj/rinkj-byte-stream.c.vsnprintf 2008-04-04 02:02:16.000000000 +0100 ++++ ghostscript-8.71/base/rinkj/rinkj-byte-stream.c 2010-02-17 11:30:13.791615392 +0000 @@ -43,7 +43,7 @@ rinkj_byte_stream_printf (RinkjByteStrea va_list ap; diff --git a/ghostscript.spec b/ghostscript.spec index 3845831..4dfeaad 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -1,11 +1,11 @@ -%define gs_ver 8.70 -%define gs_dot_ver 8.70 +%define gs_ver 8.71 +%define gs_dot_ver 8.71 %{expand: %%define build_with_freetype %{?_with_freetype:1}%{!?_with_freetype:0}} Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 6%{?dist} +Release: 1%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -173,7 +173,7 @@ do FONTPATH="$FONTPATH${FONTPATH:+:}$path" done %configure --with-ijs --enable-dynamic --with-fontpath="$FONTPATH" \ - --with-drivers=ALL --disable-compile-inits \ + --with-drivers=ALL --disable-compile-inits --with-system-libtiff \ CFLAGS="$CFLAGS $EXTRACFLAGS" # Build IJS @@ -326,6 +326,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Wed Feb 17 2010 Tim Waugh 8.71-1 +- 8.71 (bug #565935). + * Tue Feb 16 2010 Tim Waugh 8.70-6 - Reverted gdevcups duplex changes as they cause a regression (see bug #563313). diff --git a/sources b/sources index 2ae0265..1ddb496 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ 2fbae60417d42779f6488ab897dcaaf6 acro5-cmaps-2001.tar.gz dfc93dd2aaaf2b86d2fd55f654c13261 adobe-cmaps-200406.tar.gz -fec96a1fb44b73a01ba1adda55744784 ghostscript-8.70.tar.xz +5005d68f7395c2bfc4b05c1a60d9b6ba ghostscript-8.71.tar.xz From a5134c5ade8f67e8074b8c2f6ef6bd7006b73a6d Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 19 Feb 2010 10:41:27 +0000 Subject: [PATCH 09/19] - Fixed LDFLAGS when building dynamically linked executables (bug #565935). --- ghostscript-ldflags.patch | 26 ++++++++++++++++++++++++++ ghostscript.spec | 9 ++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ghostscript-ldflags.patch diff --git a/ghostscript-ldflags.patch b/ghostscript-ldflags.patch new file mode 100644 index 0000000..dbf189f --- /dev/null +++ b/ghostscript-ldflags.patch @@ -0,0 +1,26 @@ +diff -up ghostscript-8.71/base/unix-dll.mak.ldflags ghostscript-8.71/base/unix-dll.mak +--- ghostscript-8.71/base/unix-dll.mak.ldflags 2009-10-19 21:24:53.000000000 +0100 ++++ ghostscript-8.71/base/unix-dll.mak 2010-02-19 10:07:06.645044318 +0000 +@@ -88,8 +88,9 @@ $(GSSOX_XE): $(GS_SO) $(PSSRC)$(SOC_LOAD + + # ------------------------- Recursive make targets ------------------------- # + +-SODEFS=LDFLAGS='$(LDFLAGS) $(LDFLAGS_SO)'\ ++SODEFS=\ + GS_XE=$(BINDIR)/$(SOBINRELDIR)/$(GS_SONAME_MAJOR_MINOR)\ ++ GS_XE_LDFLAGS=$(LDFLAGS_SO)\ + STDIO_IMPLEMENTATION=c\ + DISPLAY_DEV=$(DD)$(SOOBJRELDIR)/display.dev\ + BINDIR=$(BINDIR)/$(SOBINRELDIR)\ +diff -up ghostscript-8.71/base/unixlink.mak.ldflags ghostscript-8.71/base/unixlink.mak +--- ghostscript-8.71/base/unixlink.mak.ldflags 2008-02-29 08:13:08.000000000 +0000 ++++ ghostscript-8.71/base/unixlink.mak 2010-02-19 10:07:06.646044276 +0000 +@@ -50,7 +50,7 @@ $(GS_A): $(obj_tr) $(ECHOGS_XE) $(INT_AR + # which has limited environment space. + ldt_tr=$(PSOBJ)ldt.tr + $(GS_XE): $(ld_tr) $(ECHOGS_XE) $(XE_ALL) $(PSOBJ)gsromfs$(COMPILE_INITS).$(OBJ) +- $(ECHOGS_XE) -w $(ldt_tr) -n - $(CCLD) $(LDFLAGS) -o $(GS_XE) ++ $(ECHOGS_XE) -w $(ldt_tr) -n - $(CCLD) $(GS_XE_LDFLAGS) $(LDFLAGS) -o $(GS_XE) + $(ECHOGS_XE) -a $(ldt_tr) -n -s $(PSOBJ)gsromfs$(COMPILE_INITS).$(OBJ) $(PSOBJ)gs.$(OBJ) -s + cat $(ld_tr) >>$(ldt_tr) + $(ECHOGS_XE) -a $(ldt_tr) -s - $(EXTRALIBS) $(STDLIBS) diff --git a/ghostscript.spec b/ghostscript.spec index 4dfeaad..9c2da87 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 1%{?dist} +Release: 2%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -29,6 +29,7 @@ Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch Patch12: ghostscript-cups-filters.patch Patch13: ghostscript-pdftoraster-exit.patch +Patch14: ghostscript-ldflags.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -140,6 +141,9 @@ rm -rf libpng zlib jpeg jasper # Fixed pdftoraster so that it waits for its sub-process to exit. %patch13 -p1 -b .pdftoraster-exit +# Fixed LDFLAGS when building dynamically linked executables (bug #565935). +%patch14 -p1 -b .ldflags + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -326,6 +330,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Fri Feb 19 2010 Tim Waugh 8.71-2 +- Fixed LDFLAGS when building dynamically linked executables (bug #565935). + * Wed Feb 17 2010 Tim Waugh 8.71-1 - 8.71 (bug #565935). From 865c7ebf9bd5503df8d7b64d7ae02ee4f23d4981 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sat, 20 Feb 2010 15:49:25 +0000 Subject: [PATCH 10/19] - Use fixed patch for LDFLAGS to make sure libgs.so gets a soname (bug #565935). --- ghostscript-ldflags.patch | 12 +++++------- ghostscript.spec | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ghostscript-ldflags.patch b/ghostscript-ldflags.patch index dbf189f..4893264 100644 --- a/ghostscript-ldflags.patch +++ b/ghostscript-ldflags.patch @@ -1,6 +1,5 @@ -diff -up ghostscript-8.71/base/unix-dll.mak.ldflags ghostscript-8.71/base/unix-dll.mak ---- ghostscript-8.71/base/unix-dll.mak.ldflags 2009-10-19 21:24:53.000000000 +0100 -+++ ghostscript-8.71/base/unix-dll.mak 2010-02-19 10:07:06.645044318 +0000 +--- ghostscript-8.71/base/unix-dll.mak 2009-10-19 21:24:53.000000000 +0100 ++++ ghostscript-8.71/base/unix-dll.mak.ldflags 2010-02-19 10:07:06.645044318 +0000 @@ -88,8 +88,9 @@ $(GSSOX_XE): $(GS_SO) $(PSSRC)$(SOC_LOAD # ------------------------- Recursive make targets ------------------------- # @@ -8,13 +7,12 @@ diff -up ghostscript-8.71/base/unix-dll.mak.ldflags ghostscript-8.71/base/unix-d -SODEFS=LDFLAGS='$(LDFLAGS) $(LDFLAGS_SO)'\ +SODEFS=\ GS_XE=$(BINDIR)/$(SOBINRELDIR)/$(GS_SONAME_MAJOR_MINOR)\ -+ GS_XE_LDFLAGS=$(LDFLAGS_SO)\ ++ GS_XE_LDFLAGS='$(LDFLAGS_SO)'\ STDIO_IMPLEMENTATION=c\ DISPLAY_DEV=$(DD)$(SOOBJRELDIR)/display.dev\ BINDIR=$(BINDIR)/$(SOBINRELDIR)\ -diff -up ghostscript-8.71/base/unixlink.mak.ldflags ghostscript-8.71/base/unixlink.mak ---- ghostscript-8.71/base/unixlink.mak.ldflags 2008-02-29 08:13:08.000000000 +0000 -+++ ghostscript-8.71/base/unixlink.mak 2010-02-19 10:07:06.646044276 +0000 +--- ghostscript-8.71/base/unixlink.mak 2008-02-29 08:13:08.000000000 +0000 ++++ ghostscript-8.71/base/unixlink.mak.ldflags 2010-02-19 10:07:06.646044276 +0000 @@ -50,7 +50,7 @@ $(GS_A): $(obj_tr) $(ECHOGS_XE) $(INT_AR # which has limited environment space. ldt_tr=$(PSOBJ)ldt.tr diff --git a/ghostscript.spec b/ghostscript.spec index 9c2da87..07fee4d 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 2%{?dist} +Release: 3%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -330,6 +330,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Sat Feb 20 2010 Tim Waugh 8.71-3 +- Use fixed patch for LDFLAGS to make sure libgs.so gets a soname + (bug #565935). + * Fri Feb 19 2010 Tim Waugh 8.71-2 - Fixed LDFLAGS when building dynamically linked executables (bug #565935). From 2c5f5bee432f275c4cfcdc9eb24b0a6df8d77e24 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sat, 20 Feb 2010 16:07:18 +0000 Subject: [PATCH 11/19] - Fixed pdf2dsc.ps (bug #565935). --- ghostscript-pdf2dsc.patch | 12 ++++++++++++ ghostscript.spec | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 ghostscript-pdf2dsc.patch diff --git a/ghostscript-pdf2dsc.patch b/ghostscript-pdf2dsc.patch new file mode 100644 index 0000000..31b6b54 --- /dev/null +++ b/ghostscript-pdf2dsc.patch @@ -0,0 +1,12 @@ +diff -up ghostscript-8.71/lib/pdf2dsc.ps.pdf2dsc ghostscript-8.71/lib/pdf2dsc.ps +--- ghostscript-8.71/lib/pdf2dsc.ps.pdf2dsc 2010-02-20 15:50:51.287734970 +0000 ++++ ghostscript-8.71/lib/pdf2dsc.ps 2010-02-20 15:51:02.902609964 +0000 +@@ -116,7 +116,7 @@ systemdict /.setsafe known { .setsafe } + DSCfile PDFname write==only + ( \(r\) file { DELAYSAFER { .setsafe } if } stopped pop\n) puts + ( pdfopen begin\n) puts +- ( copy_trailer_attrs\n) puts ++ ( process_trailer_attrs\n) puts + (%%EndSetup\n) puts + + /.hasPageLabels false def % see "Page Labels" in the PDF Reference diff --git a/ghostscript.spec b/ghostscript.spec index 07fee4d..45b6b68 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -30,6 +30,7 @@ Patch11: ghostscript-vsnprintf.patch Patch12: ghostscript-cups-filters.patch Patch13: ghostscript-pdftoraster-exit.patch Patch14: ghostscript-ldflags.patch +Patch15: ghostscript-pdf2dsc.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -144,6 +145,9 @@ rm -rf libpng zlib jpeg jasper # Fixed LDFLAGS when building dynamically linked executables (bug #565935). %patch14 -p1 -b .ldflags +# Fixed pdf2dsc.ps (bug #565935). +%patch15 -p1 -b .pdf2dsc + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -331,6 +335,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Sat Feb 20 2010 Tim Waugh 8.71-3 +- Fixed pdf2dsc.ps (bug #565935). - Use fixed patch for LDFLAGS to make sure libgs.so gets a soname (bug #565935). From d12a8ce9839eb6cd146c437c6a23698f1f0c3869 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sat, 20 Feb 2010 16:18:34 +0000 Subject: [PATCH 12/19] - Actually revert the upstream gdevcups changes (bug #563313). --- ghostscript-gdevcups-y-axis.patch | 709 ++++++++++++++++++++++++++++++ ghostscript.spec | 9 +- 2 files changed, 716 insertions(+), 2 deletions(-) create mode 100644 ghostscript-gdevcups-y-axis.patch diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch new file mode 100644 index 0000000..e135625 --- /dev/null +++ b/ghostscript-gdevcups-y-axis.patch @@ -0,0 +1,709 @@ +diff -up ghostscript-8.71/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.71/cups/gdevcups.c +--- ghostscript-8.71/cups/gdevcups.c.gdevcups-y-axis 2010-02-20 15:52:12.768609717 +0000 ++++ ghostscript-8.71/cups/gdevcups.c 2010-02-20 16:12:29.544735338 +0000 +@@ -605,6 +605,8 @@ private void + cups_get_matrix(gx_device *pdev, /* I - Device info */ + gs_matrix *pmat) /* O - Physical transform matrix */ + { ++ ppd_attr_t *backside = NULL; ++ + dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat); + + /* +@@ -618,25 +620,119 @@ cups_get_matrix(gx_device *pdev, /* I - + * Set the transform matrix... + */ + ++ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->page = %d\n", cups->page); ++ ++ if (cupsPPD) ++ { ++ backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); ++ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); ++ if (backside) { ++ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); ++ cupsPPD->flip_duplex = 0; ++ } ++ dprintf1("DEBUG2: cupsPPD->flip_duplex = %d\n", cupsPPD->flip_duplex); ++ } ++ + if (cups->landscape) + { + /* + * Do landscape orientation... + */ +- dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n"); +- pmat->xx = 0.0; +- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; ++ ++ if (cups->header.Duplex && cupsPPD && ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "Flipped"))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = 0.0; ++ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; ++ } ++ else if (cups->header.Duplex && cupsPPD && ++ (!cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "Flipped"))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = 0.0; ++ pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = (float)cups->header.HWResolution[1] * ++ ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; ++ } ++ else if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && !strcasecmp(backside->value, "Rotated")))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = 0.0; ++ pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = (float)cups->header.HWResolution[1] * ++ ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; ++ } ++ else ++ { ++ pmat->xx = 0.0; ++ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; ++ } ++ } ++ else if (cups->header.Duplex && cupsPPD && ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "Flipped"))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->xy = 0.0; ++ pmat->yx = 0.0; ++ pmat->yy = -(float)cups->header.HWResolution[1] / 72.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; ++ pmat->ty = (float)cups->header.HWResolution[1] * ++ ((float)cups->header.PageSize[1] - pdev->HWMargins[3]) / 72.0; ++ } ++ else if (cups->header.Duplex && cupsPPD && ++ (!cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "Flipped"))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->xy = 0.0; ++ pmat->yx = 0.0; ++ pmat->yy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; ++ } ++ else if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && !strcasecmp(backside->value, "Rotated")))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) ++ { ++ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->xy = 0.0; ++ pmat->yx = 0.0; ++ pmat->yy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; + } + else + { +- /* +- * Do portrait orientation... +- */ +- dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n"); + pmat->xx = (float)cups->header.HWResolution[0] / 72.0; + pmat->xy = 0.0; + pmat->yx = 0.0; +@@ -2703,16 +2799,13 @@ cups_put_params(gx_device *pdev, /* + int color_set; /* Were the color attrs set? */ + gdev_prn_space_params sp; /* Space parameter data */ + int width, /* New width of page */ +- height; /* New height of page */ +- static int width_old = 0, /* Previous width */ +- height_old = 0; /* Previous height */ ++ height; /* New height of page */ + ppd_attr_t *backside = NULL, + *backsiderequiresflippedmargins = NULL; + float swap; + int xflip = 0, + yflip = 0; + int found = 0; +- static int lastpage = 0; + + dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); + +@@ -2811,14 +2904,6 @@ cups_put_params(gx_device *pdev, /* + margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; + color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || + param_read_int(plist, "cupsBitsPerColor", &intval) == 0; +- /* We also recompute page size and margins if we simply get onto a new +- page without necessarily having a page size change in the PostScript +- code, as for some printers margins have to flipped on the back sides of +- the sheets (even pages) when printing duplex */ +- if (cups->page != lastpage) { +- size_set = 1; +- lastpage = cups->page; +- } + + stringoption(MediaClass, "MediaClass") + stringoption(MediaColor, "MediaColor") +@@ -2933,7 +3018,6 @@ cups_put_params(gx_device *pdev, /* + if (cupsPPD != NULL) + { + dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); +- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); + dprintf1("DEBUG2: cups->page = %d\n", cups->page); + dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); + +@@ -2957,13 +3041,10 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) { +- dprintf("DEBUG2: (1) Flip: X=1 Y=0\n"); ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) + yflip = 0; +- } else { +- dprintf("DEBUG2: (1) Flip: X=1 Y=1\n"); ++ else + yflip = 1; +- } + } + else if (cups->header.Duplex && + (!cups->header.Tumble && +@@ -2972,13 +3053,10 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 0; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) { +- dprintf("DEBUG2: (2) Flip: X=0 Y=1\n"); ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) + yflip = 1; +- } else { +- dprintf("DEBUG2: (2) Flip: X=0 Y=0\n"); ++ else + yflip = 0; +- } + } + else if (cups->header.Duplex && + ((!cups->header.Tumble && +@@ -2990,17 +3068,13 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "True")) { +- dprintf("DEBUG2: (3) Flip: X=1 Y=0\n"); ++ !strcasecmp(backsiderequiresflippedmargins->value, "True")) + yflip = 0; +- } else { +- dprintf("DEBUG2: (3) Flip: X=1 Y=1\n"); ++ else + yflip = 1; +- } + } + else + { +- dprintf("DEBUG2: (4) Flip: X=0 Y=0\n"); + xflip = 0; + yflip = 0; + } +@@ -3037,20 +3111,9 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif +- /* We check whether all 4 margins match with the margin info +- of the page size in the PPD. Here we check also for swapped +- left/right and top/bottom margins as the cups->HWMargins +- info can be from the previous page and there the margins +- can be swapped due to duplex printing requirements */ + (!margins_set || +- (((fabs(cups->HWMargins[0] - size->left) < 1.0 && +- fabs(cups->HWMargins[2] - size->width + size->right) < 1.0) || +- (fabs(cups->HWMargins[0] - size->width + size->right) < 1.0 && +- fabs(cups->HWMargins[2] - size->left) < 1.0)) && +- ((fabs(cups->HWMargins[1] - size->bottom) < 1.0 && +- fabs(cups->HWMargins[3] - size->length + size->top) < 1.0) || +- (fabs(cups->HWMargins[1] - size->length + size->top) < 1.0 && +- fabs(cups->HWMargins[3] - size->bottom) < 1.0))))) ++ (fabs(cups->HWMargins[0] - size->left) < 1.0 && ++ fabs(cups->HWMargins[1] - size->bottom) < 1.0))) + break; + + if (i > 0) +@@ -3092,20 +3155,9 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif +- /* We check whether all 4 margins match with the margin info +- of the page size in the PPD. Here we check also for swapped +- left/right and top/bottom margins as the cups->HWMargins +- info can be from the previous page and there the margins +- can be swapped due to duplex printing requirements */ + (!margins_set || +- (((fabs(cups->HWMargins[1] - size->left) < 1.0 && +- fabs(cups->HWMargins[3] - size->width + size->right) < 1.0) || +- (fabs(cups->HWMargins[1] - size->width + size->right) < 1.0 && +- fabs(cups->HWMargins[3] - size->left) < 1.0)) && +- ((fabs(cups->HWMargins[0] - size->bottom) < 1.0 && +- fabs(cups->HWMargins[2] - size->length + size->top) < 1.0) || +- (fabs(cups->HWMargins[0] - size->length + size->top) < 1.0 && +- fabs(cups->HWMargins[2] - size->bottom) < 1.0))))) ++ (fabs(cups->HWMargins[0] - size->left) < 1.0 && ++ fabs(cups->HWMargins[1] - size->bottom) < 1.0))) + break; + + if (i > 0) +@@ -3245,17 +3297,12 @@ cups_put_params(gx_device *pdev, /* + + /* + * Don't reallocate memory unless the device has been opened... +- * Also reallocate only if the size has actually changed... + */ + +- if (pdev->is_open && (width != width_old || height != height_old)) ++ if (pdev->is_open) + { +- +- width_old = width; +- height_old = height; +- + /* +- * Device is open and size has changed, so reallocate... ++ * Device is open, so reallocate... + */ + + dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", +@@ -3729,22 +3776,13 @@ cups_print_chunked(gx_device_printer *pd + unsigned char *srcptr, /* Pointer to data */ + *dstptr; /* Pointer to bits */ + int count; /* Count for loop */ +- int xflip, /* Flip scanline? */ +- yflip, /* Reverse scanline order? */ +- ystart, yend, ystep; /* Loop control for scanline order */ ++ int flip; /* Flip scanline? */ + ppd_attr_t *backside = NULL; + +- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); +- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); +- dprintf1("DEBUG2: cups->page = %d\n", cups->page); +- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); +- + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) { +- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); ++ if (backside) + cupsPPD->flip_duplex = 0; +- } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3754,36 +3792,19 @@ cups_print_chunked(gx_device_printer *pd + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- xflip = 1; ++ flip = 1; + else +- xflip = 0; +- if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && (!strcasecmp(backside->value, "Flipped") || +- !strcasecmp(backside->value, "Rotated"))))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) { +- yflip = 1; +- ystart = cups->height - 1; +- yend = -1; +- ystep = -1; +- } else { +- yflip = 0; +- ystart = 0; +- yend = cups->height; +- ystep = 1; +- } ++ flip = 0; + +- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", +- xflip, yflip, cups->height); ++ dprintf2("DEBUG: cups_print_chunked - flip = %d, height = %d\n", ++ flip, cups->height); + + /* + * Loop through the page bitmap and write chunked pixels, reversing as + * needed... + */ +- for (y = ystart; y != yend; y += ystep) ++ ++ for (y = 0; y < cups->height; y ++) + { + /* + * Grab the scanline data... +@@ -3795,7 +3816,7 @@ cups_print_chunked(gx_device_printer *pd + gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); + } + +- if (xflip) ++ if (flip) + { + /* + * Flip the raster data before writing it... +@@ -3949,22 +3970,13 @@ cups_print_banded(gx_device_printer *pde + unsigned char *srcptr; /* Pointer to data */ + unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ + *kptr, *lcptr, *lmptr; /* ... */ +- int xflip, /* Flip scanline? */ +- yflip, /* Reverse scanline order? */ +- ystart, yend, ystep; /* Loop control for scanline order */ ++ int flip; /* Flip scanline? */ + ppd_attr_t *backside = NULL; + +- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); +- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); +- dprintf1("DEBUG2: cups->page = %d\n", cups->page); +- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); +- + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) { +- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); ++ if (backside) + cupsPPD->flip_duplex = 0; +- } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3974,30 +3986,12 @@ cups_print_banded(gx_device_printer *pde + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- xflip = 1; ++ flip = 1; + else +- xflip = 0; +- if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && (!strcasecmp(backside->value, "Flipped") || +- !strcasecmp(backside->value, "Rotated"))))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) { +- yflip = 1; +- ystart = cups->height - 1; +- yend = -1; +- ystep = -1; +- } else { +- yflip = 0; +- ystart = 0; +- yend = cups->height; +- ystep = 1; +- } ++ flip = 0; + +- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", +- xflip, yflip, cups->height); ++ dprintf2("DEBUG: cups_print_banded - flip = %d, height = %d\n", ++ flip, cups->height); + + /* + * Loop through the page bitmap and write banded pixels... We have +@@ -4014,7 +4008,7 @@ cups_print_banded(gx_device_printer *pde + bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; + #endif /* CUPS_RASTER_SYNCv1 */ + +- for (y = ystart; y != yend; y += ystep) ++ for (y = 0; y < cups->height; y ++) + { + /* + * Grab the scanline data... +@@ -4034,7 +4028,7 @@ cups_print_banded(gx_device_printer *pde + memset(dst, 0, cups->header.cupsBytesPerLine); + else + { +- if (xflip) ++ if (flip) + cptr = dst + bandbytes - 1; + else + cptr = dst; +@@ -4053,7 +4047,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4064,7 +4058,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *yptr |= bit; + +- if (xflip) ++ if (flip) + { + if (bit < 128) + bit <<= 1; +@@ -4090,7 +4084,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *yptr |= bit; + +- if (xflip) ++ if (flip) + { + if (bit < 128) + bit <<= 1; +@@ -4120,7 +4114,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_CMYK : + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : +- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4133,7 +4127,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *kptr |= bit; + +- if (xflip) ++ if (flip) + { + if (bit < 128) + bit <<= 1; +@@ -4162,7 +4156,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *kptr |= bit; + +- if (xflip) ++ if (flip) + { + if (bit < 128) + bit <<= 1; +@@ -4188,7 +4182,7 @@ cups_print_banded(gx_device_printer *pde + } + break; + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4211,7 +4205,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x01) + *lmptr |= bit; + +- if (xflip) ++ if (flip) + { + if (bit < 128) + bit <<= 1; +@@ -4249,7 +4243,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4262,7 +4256,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 6; + +- if (xflip) ++ if (flip) + { + bit = 0x03; + cptr --; +@@ -4280,7 +4274,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 4; + +- if (xflip) ++ if (flip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4293,7 +4287,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 2; + +- if (xflip) ++ if (flip) + bit = 0x30; + else + bit = 0x03; +@@ -4306,7 +4300,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp; + +- if (xflip) ++ if (flip) + bit = 0x0c; + else + { +@@ -4326,7 +4320,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4341,7 +4335,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 6; + +- if (xflip) ++ if (flip) + { + bit = 0x03; + cptr --; +@@ -4362,7 +4356,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 4; + +- if (xflip) ++ if (flip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4377,7 +4371,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 2; + +- if (xflip) ++ if (flip) + bit = 0x30; + else + bit = 0x03; +@@ -4392,7 +4386,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp; + +- if (xflip) ++ if (flip) + bit = 0x0c; + else + { +@@ -4414,7 +4408,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4429,7 +4423,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (xflip) ++ if (flip) + { + cptr --; + mptr --; +@@ -4446,7 +4440,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!xflip) ++ if (!flip) + { + cptr ++; + mptr ++; +@@ -4463,7 +4457,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4480,7 +4474,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (xflip) ++ if (flip) + { + cptr --; + mptr --; +@@ -4500,7 +4494,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!xflip) ++ if (!flip) + { + cptr ++; + mptr ++; +@@ -4517,7 +4511,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (xflip) ++ if (flip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4540,7 +4534,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (xflip) ++ if (flip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4564,7 +4558,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (xflip) ++ if (flip) + for (x = cups->width; x > 0; x --, srcptr += 6) + { + *cptr-- = srcptr[1]; +@@ -4593,7 +4587,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (xflip) ++ if (flip) + for (x = cups->width; x > 0; x --, srcptr += 8) + { + *cptr-- = srcptr[1]; diff --git a/ghostscript.spec b/ghostscript.spec index 45b6b68..80cb497 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 3%{?dist} +Release: 4%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -31,6 +31,7 @@ Patch12: ghostscript-cups-filters.patch Patch13: ghostscript-pdftoraster-exit.patch Patch14: ghostscript-ldflags.patch Patch15: ghostscript-pdf2dsc.patch +Patch16: ghostscript-gdevcups-y-axis.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -148,6 +149,9 @@ rm -rf libpng zlib jpeg jasper # Fixed pdf2dsc.ps (bug #565935). %patch15 -p1 -b .pdf2dsc +# Actually revert the upstream gdevcups changes (bug #563313). +%patch16 -p1 -b .gdevcups-y-axis + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -334,7 +338,8 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog -* Sat Feb 20 2010 Tim Waugh 8.71-3 +* Sat Feb 20 2010 Tim Waugh 8.71-4 +- Actually revert the upstream gdevcups changes (bug #563313). - Fixed pdf2dsc.ps (bug #565935). - Use fixed patch for LDFLAGS to make sure libgs.so gets a soname (bug #565935). From 51650e03ec018de3c9c802521ba4a0fcf7463f66 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 12 Mar 2010 12:10:34 +0000 Subject: [PATCH 13/19] - Don't segfault closing tiffg3 device if opening failed (bug #571520). --- ghostscript-tif-fail-close.patch | 13 +++++++++++++ ghostscript.spec | 11 ++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ghostscript-tif-fail-close.patch diff --git a/ghostscript-tif-fail-close.patch b/ghostscript-tif-fail-close.patch new file mode 100644 index 0000000..675578b --- /dev/null +++ b/ghostscript-tif-fail-close.patch @@ -0,0 +1,13 @@ +diff -up ghostscript-8.71/base/gdevtfax.c.tif-fail-close ghostscript-8.71/base/gdevtfax.c +--- ghostscript-8.71/base/gdevtfax.c.tif-fail-close 2010-03-12 10:57:43.514750465 +0000 ++++ ghostscript-8.71/base/gdevtfax.c 2010-03-12 10:58:38.253627230 +0000 +@@ -97,7 +97,8 @@ tfax_close(gx_device * pdev) + { + gx_device_tfax *const tfdev = (gx_device_tfax *)pdev; + +- TIFFCleanup(tfdev->tif); ++ if (tfdev->tif) ++ TIFFCleanup(tfdev->tif); + + return gdev_prn_close(pdev); + } diff --git a/ghostscript.spec b/ghostscript.spec index 80cb497..8170ab2 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 4%{?dist} +Release: 4.1%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -32,6 +32,7 @@ Patch13: ghostscript-pdftoraster-exit.patch Patch14: ghostscript-ldflags.patch Patch15: ghostscript-pdf2dsc.patch Patch16: ghostscript-gdevcups-y-axis.patch +Patch17: ghostscript-tif-fail-close.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -152,6 +153,9 @@ rm -rf libpng zlib jpeg jasper # Actually revert the upstream gdevcups changes (bug #563313). %patch16 -p1 -b .gdevcups-y-axis +# Don't segfault closing tiffg3 device if opening failed (bug #571520). +%patch17 -p1 -b .tif-fail-close + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -171,6 +175,8 @@ for i in man/de/*.1; do from8859_1 "$i"; done # zfunc0.c zfunc3.c zfunc4.c zpcolor.c zshade.c EXTRACFLAGS="-fno-strict-aliasing" +rm -rf tiff + FONTPATH= for path in \ %{_datadir}/fonts/default/%{name} \ @@ -338,6 +344,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Fri Mar 12 2010 Tim Waugh 8.71-4.1 +- Don't segfault closing tiffg3 device if opening failed (bug #571520). + * Sat Feb 20 2010 Tim Waugh 8.71-4 - Actually revert the upstream gdevcups changes (bug #563313). - Fixed pdf2dsc.ps (bug #565935). From 130b322cda0cc8de43a2bcbccc323c68d22dc373 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mon, 15 Mar 2010 16:29:24 +0000 Subject: [PATCH 14/19] - Don't revert gdevcups y-axis change (bug #541604). - Reallocate memory in gdevcups when color depth changes (bug #563313). --- ghostscript-cups-realloc-color-depth.patch | 78 +++ ghostscript-gdevcups-y-axis.patch | 709 --------------------- ghostscript.spec | 12 +- 3 files changed, 86 insertions(+), 713 deletions(-) create mode 100644 ghostscript-cups-realloc-color-depth.patch delete mode 100644 ghostscript-gdevcups-y-axis.patch diff --git a/ghostscript-cups-realloc-color-depth.patch b/ghostscript-cups-realloc-color-depth.patch new file mode 100644 index 0000000..4e87c1c --- /dev/null +++ b/ghostscript-cups-realloc-color-depth.patch @@ -0,0 +1,78 @@ +diff -up ghostscript-8.71/cups/gdevcups.c.cups-realloc-color-depth ghostscript-8.71/cups/gdevcups.c +--- ghostscript-8.71/cups/gdevcups.c.cups-realloc-color-depth 2010-03-15 14:38:08.155372454 +0000 ++++ ghostscript-8.71/cups/gdevcups.c 2010-03-15 14:38:12.208372310 +0000 +@@ -975,7 +975,8 @@ cups_map_cmyk(gx_device *pdev, /* I - D + frac k, /* I - Black value */ + frac *out) /* O - Device colors */ + { +- int c0, c1, c2, c3; /* Temporary color values */ ++ int c0 = 0, c1 = 0, ++ c2 = 0, c3 = 0; /* Temporary color values */ + float rr, rg, rb, /* Real RGB colors */ + ciex, ciey, ciez, /* CIE XYZ colors */ + ciey_yn, /* Normalized luminance */ +@@ -2703,9 +2704,13 @@ cups_put_params(gx_device *pdev, /* + int color_set; /* Were the color attrs set? */ + gdev_prn_space_params sp; /* Space parameter data */ + int width, /* New width of page */ +- height; /* New height of page */ ++ height, /* New height of page */ ++ colorspace, /* New color space */ ++ bitspercolor; /* New bits per color */ + static int width_old = 0, /* Previous width */ +- height_old = 0; /* Previous height */ ++ height_old = 0, /* Previous height */ ++ colorspace_old = 0,/* Previous color space */ ++ bitspercolor_old = 0;/* Previous bits per color */ + ppd_attr_t *backside = NULL, + *backsiderequiresflippedmargins = NULL; + float swap; +@@ -2800,9 +2805,10 @@ cups_put_params(gx_device *pdev, /* + else if (code == 0) \ + { \ + dprintf1("DEBUG: Setting %s to", sname); \ +- for (i = 0; i < count; i ++) \ +- dprintf1(" %d", (unsigned)(arrayval.data[i])); \ +- cups->header.name[i] = (unsigned)arrayval.data[i]; \ ++ for (i = 0; i < count; i ++) { \ ++ dprintf1(" %d", (unsigned)(arrayval.data[i])); \ ++ cups->header.name[i] = (unsigned)(arrayval.data[i]); \ ++ } \ + dprintf("...\n"); \ + } + +@@ -3243,23 +3249,31 @@ cups_put_params(gx_device *pdev, /* + } + #endif /* CUPS_RASTER_SYNCv1 */ + ++ colorspace = cups->header.cupsColorSpace; ++ bitspercolor = cups->header.cupsBitsPerColor; ++ + /* + * Don't reallocate memory unless the device has been opened... + * Also reallocate only if the size has actually changed... + */ + +- if (pdev->is_open && (width != width_old || height != height_old)) ++ if (pdev->is_open && ++ (width != width_old || height != height_old || ++ colorspace != colorspace_old || bitspercolor != bitspercolor_old)) + { + + width_old = width; + height_old = height; ++ colorspace_old = colorspace; ++ bitspercolor_old = bitspercolor; + + /* + * Device is open and size has changed, so reallocate... + */ + +- dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", +- pdev->MediaSize[0], pdev->MediaSize[1], width, height); ++ dprintf6("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels, color space: %d, bits per color: %d...\n", ++ pdev->MediaSize[0], pdev->MediaSize[1], width, height, ++ colorspace, bitspercolor); + + sp = ((gx_device_printer *)pdev)->space_params; + diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch deleted file mode 100644 index e135625..0000000 --- a/ghostscript-gdevcups-y-axis.patch +++ /dev/null @@ -1,709 +0,0 @@ -diff -up ghostscript-8.71/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.71/cups/gdevcups.c ---- ghostscript-8.71/cups/gdevcups.c.gdevcups-y-axis 2010-02-20 15:52:12.768609717 +0000 -+++ ghostscript-8.71/cups/gdevcups.c 2010-02-20 16:12:29.544735338 +0000 -@@ -605,6 +605,8 @@ private void - cups_get_matrix(gx_device *pdev, /* I - Device info */ - gs_matrix *pmat) /* O - Physical transform matrix */ - { -+ ppd_attr_t *backside = NULL; -+ - dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat); - - /* -@@ -618,25 +620,119 @@ cups_get_matrix(gx_device *pdev, /* I - - * Set the transform matrix... - */ - -+ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -+ dprintf1("DEBUG2: cups->page = %d\n", cups->page); -+ -+ if (cupsPPD) -+ { -+ backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -+ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -+ if (backside) { -+ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); -+ cupsPPD->flip_duplex = 0; -+ } -+ dprintf1("DEBUG2: cupsPPD->flip_duplex = %d\n", cupsPPD->flip_duplex); -+ } -+ - if (cups->landscape) - { - /* - * Do landscape orientation... - */ -- dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n"); -- pmat->xx = 0.0; -- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -- pmat->yy = 0.0; -- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; -+ -+ if (cups->header.Duplex && cupsPPD && -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "Flipped"))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = 0.0; -+ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -+ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->yy = 0.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -+ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; -+ } -+ else if (cups->header.Duplex && cupsPPD && -+ (!cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "Flipped"))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = 0.0; -+ pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; -+ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->yy = 0.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -+ pmat->ty = (float)cups->header.HWResolution[1] * -+ ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; -+ } -+ else if (cups->header.Duplex && cupsPPD && -+ ((!cups->header.Tumble && -+ (cupsPPD->flip_duplex || -+ (backside && !strcasecmp(backside->value, "Rotated")))) || -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "ManualTumble")))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = 0.0; -+ pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; -+ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->yy = 0.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -+ pmat->ty = (float)cups->header.HWResolution[1] * -+ ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; -+ } -+ else -+ { -+ pmat->xx = 0.0; -+ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; -+ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->yy = 0.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; -+ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; -+ } -+ } -+ else if (cups->header.Duplex && cupsPPD && -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "Flipped"))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->xy = 0.0; -+ pmat->yx = 0.0; -+ pmat->yy = -(float)cups->header.HWResolution[1] / 72.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -+ pmat->ty = (float)cups->header.HWResolution[1] * -+ ((float)cups->header.PageSize[1] - pdev->HWMargins[3]) / 72.0; -+ } -+ else if (cups->header.Duplex && cupsPPD && -+ (!cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "Flipped"))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->xy = 0.0; -+ pmat->yx = 0.0; -+ pmat->yy = (float)cups->header.HWResolution[1] / 72.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -+ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; -+ } -+ else if (cups->header.Duplex && cupsPPD && -+ ((!cups->header.Tumble && -+ (cupsPPD->flip_duplex || -+ (backside && !strcasecmp(backside->value, "Rotated")))) || -+ (cups->header.Tumble && -+ (backside && !strcasecmp(backside->value, "ManualTumble")))) && -+ !(cups->page & 1)) -+ { -+ pmat->xx = (float)cups->header.HWResolution[0] / 72.0; -+ pmat->xy = 0.0; -+ pmat->yx = 0.0; -+ pmat->yy = (float)cups->header.HWResolution[1] / 72.0; -+ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; -+ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; - } - else - { -- /* -- * Do portrait orientation... -- */ -- dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n"); - pmat->xx = (float)cups->header.HWResolution[0] / 72.0; - pmat->xy = 0.0; - pmat->yx = 0.0; -@@ -2703,16 +2799,13 @@ cups_put_params(gx_device *pdev, /* - int color_set; /* Were the color attrs set? */ - gdev_prn_space_params sp; /* Space parameter data */ - int width, /* New width of page */ -- height; /* New height of page */ -- static int width_old = 0, /* Previous width */ -- height_old = 0; /* Previous height */ -+ height; /* New height of page */ - ppd_attr_t *backside = NULL, - *backsiderequiresflippedmargins = NULL; - float swap; - int xflip = 0, - yflip = 0; - int found = 0; -- static int lastpage = 0; - - dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); - -@@ -2811,14 +2904,6 @@ cups_put_params(gx_device *pdev, /* - margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; - color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || - param_read_int(plist, "cupsBitsPerColor", &intval) == 0; -- /* We also recompute page size and margins if we simply get onto a new -- page without necessarily having a page size change in the PostScript -- code, as for some printers margins have to flipped on the back sides of -- the sheets (even pages) when printing duplex */ -- if (cups->page != lastpage) { -- size_set = 1; -- lastpage = cups->page; -- } - - stringoption(MediaClass, "MediaClass") - stringoption(MediaColor, "MediaColor") -@@ -2933,7 +3018,6 @@ cups_put_params(gx_device *pdev, /* - if (cupsPPD != NULL) - { - dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); - dprintf1("DEBUG2: cups->page = %d\n", cups->page); - dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); - -@@ -2957,13 +3041,10 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 1; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "False")) { -- dprintf("DEBUG2: (1) Flip: X=1 Y=0\n"); -+ !strcasecmp(backsiderequiresflippedmargins->value, "False")) - yflip = 0; -- } else { -- dprintf("DEBUG2: (1) Flip: X=1 Y=1\n"); -+ else - yflip = 1; -- } - } - else if (cups->header.Duplex && - (!cups->header.Tumble && -@@ -2972,13 +3053,10 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 0; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "False")) { -- dprintf("DEBUG2: (2) Flip: X=0 Y=1\n"); -+ !strcasecmp(backsiderequiresflippedmargins->value, "False")) - yflip = 1; -- } else { -- dprintf("DEBUG2: (2) Flip: X=0 Y=0\n"); -+ else - yflip = 0; -- } - } - else if (cups->header.Duplex && - ((!cups->header.Tumble && -@@ -2990,17 +3068,13 @@ cups_put_params(gx_device *pdev, /* - { - xflip = 1; - if (backsiderequiresflippedmargins && -- !strcasecmp(backsiderequiresflippedmargins->value, "True")) { -- dprintf("DEBUG2: (3) Flip: X=1 Y=0\n"); -+ !strcasecmp(backsiderequiresflippedmargins->value, "True")) - yflip = 0; -- } else { -- dprintf("DEBUG2: (3) Flip: X=1 Y=1\n"); -+ else - yflip = 1; -- } - } - else - { -- dprintf("DEBUG2: (4) Flip: X=0 Y=0\n"); - xflip = 0; - yflip = 0; - } -@@ -3037,20 +3111,9 @@ cups_put_params(gx_device *pdev, /* - ((strlen(cups->header.cupsPageSizeName) == 0) || - (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && - #endif -- /* We check whether all 4 margins match with the margin info -- of the page size in the PPD. Here we check also for swapped -- left/right and top/bottom margins as the cups->HWMargins -- info can be from the previous page and there the margins -- can be swapped due to duplex printing requirements */ - (!margins_set || -- (((fabs(cups->HWMargins[0] - size->left) < 1.0 && -- fabs(cups->HWMargins[2] - size->width + size->right) < 1.0) || -- (fabs(cups->HWMargins[0] - size->width + size->right) < 1.0 && -- fabs(cups->HWMargins[2] - size->left) < 1.0)) && -- ((fabs(cups->HWMargins[1] - size->bottom) < 1.0 && -- fabs(cups->HWMargins[3] - size->length + size->top) < 1.0) || -- (fabs(cups->HWMargins[1] - size->length + size->top) < 1.0 && -- fabs(cups->HWMargins[3] - size->bottom) < 1.0))))) -+ (fabs(cups->HWMargins[0] - size->left) < 1.0 && -+ fabs(cups->HWMargins[1] - size->bottom) < 1.0))) - break; - - if (i > 0) -@@ -3092,20 +3155,9 @@ cups_put_params(gx_device *pdev, /* - ((strlen(cups->header.cupsPageSizeName) == 0) || - (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && - #endif -- /* We check whether all 4 margins match with the margin info -- of the page size in the PPD. Here we check also for swapped -- left/right and top/bottom margins as the cups->HWMargins -- info can be from the previous page and there the margins -- can be swapped due to duplex printing requirements */ - (!margins_set || -- (((fabs(cups->HWMargins[1] - size->left) < 1.0 && -- fabs(cups->HWMargins[3] - size->width + size->right) < 1.0) || -- (fabs(cups->HWMargins[1] - size->width + size->right) < 1.0 && -- fabs(cups->HWMargins[3] - size->left) < 1.0)) && -- ((fabs(cups->HWMargins[0] - size->bottom) < 1.0 && -- fabs(cups->HWMargins[2] - size->length + size->top) < 1.0) || -- (fabs(cups->HWMargins[0] - size->length + size->top) < 1.0 && -- fabs(cups->HWMargins[2] - size->bottom) < 1.0))))) -+ (fabs(cups->HWMargins[0] - size->left) < 1.0 && -+ fabs(cups->HWMargins[1] - size->bottom) < 1.0))) - break; - - if (i > 0) -@@ -3245,17 +3297,12 @@ cups_put_params(gx_device *pdev, /* - - /* - * Don't reallocate memory unless the device has been opened... -- * Also reallocate only if the size has actually changed... - */ - -- if (pdev->is_open && (width != width_old || height != height_old)) -+ if (pdev->is_open) - { -- -- width_old = width; -- height_old = height; -- - /* -- * Device is open and size has changed, so reallocate... -+ * Device is open, so reallocate... - */ - - dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", -@@ -3729,22 +3776,13 @@ cups_print_chunked(gx_device_printer *pd - unsigned char *srcptr, /* Pointer to data */ - *dstptr; /* Pointer to bits */ - int count; /* Count for loop */ -- int xflip, /* Flip scanline? */ -- yflip, /* Reverse scanline order? */ -- ystart, yend, ystep; /* Loop control for scanline order */ -+ int flip; /* Flip scanline? */ - ppd_attr_t *backside = NULL; - -- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); -- dprintf1("DEBUG2: cups->page = %d\n", cups->page); -- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -- - if (cupsPPD) { - backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -- if (backside) { -- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); -+ if (backside) - cupsPPD->flip_duplex = 0; -- } - } - if (cups->header.Duplex && cupsPPD && - ((!cups->header.Tumble && -@@ -3754,36 +3792,19 @@ cups_print_chunked(gx_device_printer *pd - (backside && (!strcasecmp(backside->value, "Flipped") || - !strcasecmp(backside->value, "ManualTumble"))))) && - !(cups->page & 1)) -- xflip = 1; -+ flip = 1; - else -- xflip = 0; -- if (cups->header.Duplex && cupsPPD && -- ((!cups->header.Tumble && -- (cupsPPD->flip_duplex || -- (backside && (!strcasecmp(backside->value, "Flipped") || -- !strcasecmp(backside->value, "Rotated"))))) || -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "ManualTumble")))) && -- !(cups->page & 1)) { -- yflip = 1; -- ystart = cups->height - 1; -- yend = -1; -- ystep = -1; -- } else { -- yflip = 0; -- ystart = 0; -- yend = cups->height; -- ystep = 1; -- } -+ flip = 0; - -- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", -- xflip, yflip, cups->height); -+ dprintf2("DEBUG: cups_print_chunked - flip = %d, height = %d\n", -+ flip, cups->height); - - /* - * Loop through the page bitmap and write chunked pixels, reversing as - * needed... - */ -- for (y = ystart; y != yend; y += ystep) -+ -+ for (y = 0; y < cups->height; y ++) - { - /* - * Grab the scanline data... -@@ -3795,7 +3816,7 @@ cups_print_chunked(gx_device_printer *pd - gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); - } - -- if (xflip) -+ if (flip) - { - /* - * Flip the raster data before writing it... -@@ -3949,22 +3970,13 @@ cups_print_banded(gx_device_printer *pde - unsigned char *srcptr; /* Pointer to data */ - unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ - *kptr, *lcptr, *lmptr; /* ... */ -- int xflip, /* Flip scanline? */ -- yflip, /* Reverse scanline order? */ -- ystart, yend, ystep; /* Loop control for scanline order */ -+ int flip; /* Flip scanline? */ - ppd_attr_t *backside = NULL; - -- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); -- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); -- dprintf1("DEBUG2: cups->page = %d\n", cups->page); -- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); -- - if (cupsPPD) { - backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); -- if (backside) { -- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); -+ if (backside) - cupsPPD->flip_duplex = 0; -- } - } - if (cups->header.Duplex && cupsPPD && - ((!cups->header.Tumble && -@@ -3974,30 +3986,12 @@ cups_print_banded(gx_device_printer *pde - (backside && (!strcasecmp(backside->value, "Flipped") || - !strcasecmp(backside->value, "ManualTumble"))))) && - !(cups->page & 1)) -- xflip = 1; -+ flip = 1; - else -- xflip = 0; -- if (cups->header.Duplex && cupsPPD && -- ((!cups->header.Tumble && -- (cupsPPD->flip_duplex || -- (backside && (!strcasecmp(backside->value, "Flipped") || -- !strcasecmp(backside->value, "Rotated"))))) || -- (cups->header.Tumble && -- (backside && !strcasecmp(backside->value, "ManualTumble")))) && -- !(cups->page & 1)) { -- yflip = 1; -- ystart = cups->height - 1; -- yend = -1; -- ystep = -1; -- } else { -- yflip = 0; -- ystart = 0; -- yend = cups->height; -- ystep = 1; -- } -+ flip = 0; - -- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", -- xflip, yflip, cups->height); -+ dprintf2("DEBUG: cups_print_banded - flip = %d, height = %d\n", -+ flip, cups->height); - - /* - * Loop through the page bitmap and write banded pixels... We have -@@ -4014,7 +4008,7 @@ cups_print_banded(gx_device_printer *pde - bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; - #endif /* CUPS_RASTER_SYNCv1 */ - -- for (y = ystart; y != yend; y += ystep) -+ for (y = 0; y < cups->height; y ++) - { - /* - * Grab the scanline data... -@@ -4034,7 +4028,7 @@ cups_print_banded(gx_device_printer *pde - memset(dst, 0, cups->header.cupsBytesPerLine); - else - { -- if (xflip) -+ if (flip) - cptr = dst + bandbytes - 1; - else - cptr = dst; -@@ -4053,7 +4047,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4064,7 +4058,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x10) - *yptr |= bit; - -- if (xflip) -+ if (flip) - { - if (bit < 128) - bit <<= 1; -@@ -4090,7 +4084,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x1) - *yptr |= bit; - -- if (xflip) -+ if (flip) - { - if (bit < 128) - bit <<= 1; -@@ -4120,7 +4114,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_CMYK : - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : -- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4133,7 +4127,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x10) - *kptr |= bit; - -- if (xflip) -+ if (flip) - { - if (bit < 128) - bit <<= 1; -@@ -4162,7 +4156,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x1) - *kptr |= bit; - -- if (xflip) -+ if (flip) - { - if (bit < 128) - bit <<= 1; -@@ -4188,7 +4182,7 @@ cups_print_banded(gx_device_printer *pde - } - break; - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; -+ for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; - x > 0; - x --, srcptr ++) - { -@@ -4211,7 +4205,7 @@ cups_print_banded(gx_device_printer *pde - if (*srcptr & 0x01) - *lmptr |= bit; - -- if (xflip) -+ if (flip) - { - if (bit < 128) - bit <<= 1; -@@ -4249,7 +4243,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; -+ for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; - x > 0; - x --, srcptr ++) - switch (bit) -@@ -4262,7 +4256,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 6; - -- if (xflip) -+ if (flip) - { - bit = 0x03; - cptr --; -@@ -4280,7 +4274,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 4; - -- if (xflip) -+ if (flip) - bit = 0xc0; - else - bit = 0x0c; -@@ -4293,7 +4287,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp << 2; - -- if (xflip) -+ if (flip) - bit = 0x30; - else - bit = 0x03; -@@ -4306,7 +4300,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *yptr |= temp; - -- if (xflip) -+ if (flip) - bit = 0x0c; - else - { -@@ -4326,7 +4320,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; -+ for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; - x > 0; - x --, srcptr ++) - switch (bit) -@@ -4341,7 +4335,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 6; - -- if (xflip) -+ if (flip) - { - bit = 0x03; - cptr --; -@@ -4362,7 +4356,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 4; - -- if (xflip) -+ if (flip) - bit = 0xc0; - else - bit = 0x0c; -@@ -4377,7 +4371,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp << 2; - -- if (xflip) -+ if (flip) - bit = 0x30; - else - bit = 0x03; -@@ -4392,7 +4386,7 @@ cups_print_banded(gx_device_printer *pde - if ((temp = *srcptr & 0x03) != 0) - *kptr |= temp; - -- if (xflip) -+ if (flip) - bit = 0x0c; - else - { -@@ -4414,7 +4408,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; -+ for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; - x > 0; - x --, srcptr += 2) - switch (bit) -@@ -4429,7 +4423,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0x0f; - -- if (xflip) -+ if (flip) - { - cptr --; - mptr --; -@@ -4446,7 +4440,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0xf0; - -- if (!xflip) -+ if (!flip) - { - cptr ++; - mptr ++; -@@ -4463,7 +4457,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; -+ for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; - x > 0; - x --, srcptr += 2) - switch (bit) -@@ -4480,7 +4474,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0x0f; - -- if (xflip) -+ if (flip) - { - cptr --; - mptr --; -@@ -4500,7 +4494,7 @@ cups_print_banded(gx_device_printer *pde - - bit = 0xf0; - -- if (!xflip) -+ if (!flip) - { - cptr ++; - mptr ++; -@@ -4517,7 +4511,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- if (xflip) -+ if (flip) - for (x = cups->width; x > 0; x --) - { - *cptr-- = *srcptr++; -@@ -4540,7 +4534,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- if (xflip) -+ if (flip) - for (x = cups->width; x > 0; x --) - { - *cptr-- = *srcptr++; -@@ -4564,7 +4558,7 @@ cups_print_banded(gx_device_printer *pde - switch (cups->header.cupsColorSpace) - { - default : -- if (xflip) -+ if (flip) - for (x = cups->width; x > 0; x --, srcptr += 6) - { - *cptr-- = srcptr[1]; -@@ -4593,7 +4587,7 @@ cups_print_banded(gx_device_printer *pde - case CUPS_CSPACE_YMCK : - case CUPS_CSPACE_KCMY : - case CUPS_CSPACE_KCMYcm : -- if (xflip) -+ if (flip) - for (x = cups->width; x > 0; x --, srcptr += 8) - { - *cptr-- = srcptr[1]; diff --git a/ghostscript.spec b/ghostscript.spec index 8170ab2..f508449 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 4.1%{?dist} +Release: 5%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -31,7 +31,7 @@ Patch12: ghostscript-cups-filters.patch Patch13: ghostscript-pdftoraster-exit.patch Patch14: ghostscript-ldflags.patch Patch15: ghostscript-pdf2dsc.patch -Patch16: ghostscript-gdevcups-y-axis.patch +Patch16: ghostscript-cups-realloc-color-depth.patch Patch17: ghostscript-tif-fail-close.patch Requires: urw-fonts >= 1.1, ghostscript-fonts @@ -150,8 +150,8 @@ rm -rf libpng zlib jpeg jasper # Fixed pdf2dsc.ps (bug #565935). %patch15 -p1 -b .pdf2dsc -# Actually revert the upstream gdevcups changes (bug #563313). -%patch16 -p1 -b .gdevcups-y-axis +# Reallocate memory in gdevcups when color depth changes (bug #563313). +%patch16 -p1 -b .cups-realloc-color-depth # Don't segfault closing tiffg3 device if opening failed (bug #571520). %patch17 -p1 -b .tif-fail-close @@ -344,6 +344,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Mon Mar 15 2010 Tim Waugh 8.71-5 +- Don't revert gdevcups y-axis change (bug #541604). +- Reallocate memory in gdevcups when color depth changes (bug #563313). + * Fri Mar 12 2010 Tim Waugh 8.71-4.1 - Don't segfault closing tiffg3 device if opening failed (bug #571520). From ba097d7d21a73318af5341d0b565d5182cc9e773 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mon, 15 Mar 2010 17:09:41 +0000 Subject: [PATCH 15/19] - Restore the TIFF default strip size of 0 (bug #571520). --- ghostscript-tiff-default-strip-size.patch | 12 ++++++++++++ ghostscript.spec | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 ghostscript-tiff-default-strip-size.patch diff --git a/ghostscript-tiff-default-strip-size.patch b/ghostscript-tiff-default-strip-size.patch new file mode 100644 index 0000000..ee9f318 --- /dev/null +++ b/ghostscript-tiff-default-strip-size.patch @@ -0,0 +1,12 @@ +diff -up ghostscript-8.71/base/gdevtifs.h.tiff-default-strip-size ghostscript-8.71/base/gdevtifs.h +--- ghostscript-8.71/base/gdevtifs.h.tiff-default-strip-size 2010-03-15 16:42:06.892248676 +0000 ++++ ghostscript-8.71/base/gdevtifs.h 2010-03-15 16:42:26.890373466 +0000 +@@ -50,7 +50,7 @@ int tiff_print_page(gx_device_printer *d + * Sets the compression tag for TIFF and updates the rows_per_strip tag to + * reflect max_strip_size under the new compression scheme. + */ +-#define TIFF_DEFAULT_STRIP_SIZE 8192 ++#define TIFF_DEFAULT_STRIP_SIZE 0 + + int tiff_set_compression(gx_device_printer *pdev, + TIFF *tif, diff --git a/ghostscript.spec b/ghostscript.spec index f508449..a826192 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -33,6 +33,7 @@ Patch14: ghostscript-ldflags.patch Patch15: ghostscript-pdf2dsc.patch Patch16: ghostscript-cups-realloc-color-depth.patch Patch17: ghostscript-tif-fail-close.patch +Patch18: ghostscript-tiff-default-strip-size.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -156,6 +157,9 @@ rm -rf libpng zlib jpeg jasper # Don't segfault closing tiffg3 device if opening failed (bug #571520). %patch17 -p1 -b .tif-fail-close +# Restore the TIFF default strip size of 0 (bug #571520). +%patch18 -p1 -b .tiff-default-strip-size + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -345,6 +349,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Mon Mar 15 2010 Tim Waugh 8.71-5 +- Restore the TIFF default strip size of 0 (bug #571520). - Don't revert gdevcups y-axis change (bug #541604). - Reallocate memory in gdevcups when color depth changes (bug #563313). From 561959feca9727b17e676dde4e754ae72b731511 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Tue, 16 Mar 2010 10:02:37 +0000 Subject: [PATCH 16/19] - Use upstream fix for TIFF default strip size (bug #571520). --- ghostscript-tiff-default-strip-size.patch | 6 +++--- ghostscript.spec | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ghostscript-tiff-default-strip-size.patch b/ghostscript-tiff-default-strip-size.patch index ee9f318..59d3815 100644 --- a/ghostscript-tiff-default-strip-size.patch +++ b/ghostscript-tiff-default-strip-size.patch @@ -1,12 +1,12 @@ diff -up ghostscript-8.71/base/gdevtifs.h.tiff-default-strip-size ghostscript-8.71/base/gdevtifs.h ---- ghostscript-8.71/base/gdevtifs.h.tiff-default-strip-size 2010-03-15 16:42:06.892248676 +0000 -+++ ghostscript-8.71/base/gdevtifs.h 2010-03-15 16:42:26.890373466 +0000 +--- ghostscript-8.71/base/gdevtifs.h.tiff-default-strip-size 2010-02-04 17:47:57.000000000 +0000 ++++ ghostscript-8.71/base/gdevtifs.h 2010-03-16 09:58:29.269600052 +0000 @@ -50,7 +50,7 @@ int tiff_print_page(gx_device_printer *d * Sets the compression tag for TIFF and updates the rows_per_strip tag to * reflect max_strip_size under the new compression scheme. */ -#define TIFF_DEFAULT_STRIP_SIZE 8192 -+#define TIFF_DEFAULT_STRIP_SIZE 0 ++#define TIFF_DEFAULT_STRIP_SIZE 1048576 int tiff_set_compression(gx_device_printer *pdev, TIFF *tif, diff --git a/ghostscript.spec b/ghostscript.spec index a826192..5c03a24 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 5%{?dist} +Release: 6%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -348,6 +348,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Tue Mar 16 2010 Tim Waugh 8.71-6 +- Use upstream fix for TIFF default strip size (bug #571520). + * Mon Mar 15 2010 Tim Waugh 8.71-5 - Restore the TIFF default strip size of 0 (bug #571520). - Don't revert gdevcups y-axis change (bug #541604). From 9156a8754c8b34bdf6c6136762331f1b0cba7d10 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Tue, 16 Mar 2010 13:29:23 +0000 Subject: [PATCH 17/19] - Backported some more TIFF fixes (bug #573970). --- ghostscript-tiff-fixes.patch | 59 ++++++++++++++++++++++++++++++++++++ ghostscript.spec | 5 +++ 2 files changed, 64 insertions(+) create mode 100644 ghostscript-tiff-fixes.patch diff --git a/ghostscript-tiff-fixes.patch b/ghostscript-tiff-fixes.patch new file mode 100644 index 0000000..326a27e --- /dev/null +++ b/ghostscript-tiff-fixes.patch @@ -0,0 +1,59 @@ +diff -up ghostscript-8.71/base/gdevtfnx.c.tiff-fixes ghostscript-8.71/base/gdevtfnx.c +--- ghostscript-8.71/base/gdevtfnx.c.tiff-fixes 2010-02-04 17:47:57.000000000 +0000 ++++ ghostscript-8.71/base/gdevtfnx.c 2010-03-16 10:04:00.686600827 +0000 +@@ -105,6 +105,8 @@ tiff12_print_page(gx_device_printer * pd + TIFFSetField(tfdev->tif, TIFFTAG_BITSPERSAMPLE, 4); + tiff_set_rgb_fields(tfdev); + ++ TIFFCheckpointDirectory(tfdev->tif); ++ + /* Write the page data. */ + { + int y; +diff -up ghostscript-8.71/base/gdevtifs.c.tiff-fixes ghostscript-8.71/base/gdevtifs.c +--- ghostscript-8.71/base/gdevtifs.c.tiff-fixes 2010-02-04 17:47:57.000000000 +0000 ++++ ghostscript-8.71/base/gdevtifs.c 2010-03-16 10:04:00.689600292 +0000 +@@ -243,8 +243,8 @@ int tiff_set_fields_for_printer(gx_devic + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); +- TIFFSetField(tif, TIFFTAG_XRESOLUTION, pdev->x_pixels_per_inch); +- TIFFSetField(tif, TIFFTAG_YRESOLUTION, pdev->y_pixels_per_inch); ++ TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)pdev->x_pixels_per_inch); ++ TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float)pdev->y_pixels_per_inch); + + { + char revs[10]; +@@ -293,6 +293,8 @@ tiff_print_page(gx_device_printer *dev, + if (data == NULL) + return_error(gs_error_VMerror); + ++ TIFFCheckpointDirectory(tif); ++ + memset(data, 0, max_size); + for (row = 0; row < dev->height; row++) { + code = gdev_prn_copy_scan_lines(dev, row, data, size); +diff -up ghostscript-8.71/base/gdevtsep.c.tiff-fixes ghostscript-8.71/base/gdevtsep.c +--- ghostscript-8.71/base/gdevtsep.c.tiff-fixes 2010-02-04 17:47:57.000000000 +0000 ++++ ghostscript-8.71/base/gdevtsep.c 2010-03-16 10:04:00.700601143 +0000 +@@ -1438,6 +1438,10 @@ tiffsep_print_page(gx_device_printer * p + return_error(gs_error_VMerror); + } + ++ for (comp_num = 0; comp_num < num_comp; comp_num++ ) ++ TIFFCheckpointDirectory(tfdev->tiff[comp_num]); ++ TIFFCheckpointDirectory(tfdev->tiff_comp); ++ + /* Write the page data. */ + for (y = 0; y < pdev->height; ++y) { + code = gdev_prn_get_bits(pdev, y, line, &row); +@@ -1603,6 +1607,9 @@ tiffsep1_print_page(gx_device_printer * + if (line == NULL || unpacked == NULL || dithered_line == NULL) + return_error(gs_error_VMerror); + ++ for (comp_num = 0; comp_num < num_comp; comp_num++ ) ++ TIFFCheckpointDirectory(tfdev->tiff[comp_num]); ++ + /* Loop for the lines */ + for (y = 0; y < pdev->height; ++y) { + code = gdev_prn_get_bits(pdev, y, line, &row); diff --git a/ghostscript.spec b/ghostscript.spec index 5c03a24..21f2db8 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -34,6 +34,7 @@ Patch15: ghostscript-pdf2dsc.patch Patch16: ghostscript-cups-realloc-color-depth.patch Patch17: ghostscript-tif-fail-close.patch Patch18: ghostscript-tiff-default-strip-size.patch +Patch19: ghostscript-tiff-fixes.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -160,6 +161,9 @@ rm -rf libpng zlib jpeg jasper # Restore the TIFF default strip size of 0 (bug #571520). %patch18 -p1 -b .tiff-default-strip-size +# Backported some more TIFF fixes (bug #573970). +%patch19 -p1 -b .tiff-fixes + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -349,6 +353,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Tue Mar 16 2010 Tim Waugh 8.71-6 +- Backported some more TIFF fixes (bug #573970). - Use upstream fix for TIFF default strip size (bug #571520). * Mon Mar 15 2010 Tim Waugh 8.71-5 From 02461c194f93bc4403e89a634edcfa459fc22884 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 16 Jul 2010 12:51:28 +0000 Subject: [PATCH 18/19] - Applied patch to fix CVE-2010-1628 (memory corruption at PS stack overflow, bug #592492). --- ghostscript-CVE-2010-1628.patch | 124 ++++++++++++++++++++++++++++++++ ghostscript.spec | 11 ++- 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 ghostscript-CVE-2010-1628.patch diff --git a/ghostscript-CVE-2010-1628.patch b/ghostscript-CVE-2010-1628.patch new file mode 100644 index 0000000..428d4c0 --- /dev/null +++ b/ghostscript-CVE-2010-1628.patch @@ -0,0 +1,124 @@ +diff -up ghostscript-8.70/psi/ialloc.c.CVE-2010-1628 ghostscript-8.70/psi/ialloc.c +--- ghostscript-8.70/psi/ialloc.c.CVE-2010-1628 2008-08-28 23:48:19.000000000 +0100 ++++ ghostscript-8.70/psi/ialloc.c 2010-07-16 12:15:45.230948203 +0100 +@@ -185,7 +185,14 @@ gs_alloc_ref_array(gs_ref_memory_t * mem + */ + chunk_t *pcc = mem->pcc; + ref *end; ++ alloc_change_t *cp = 0; ++ int code = 0; + ++ if ((gs_memory_t *)mem != mem->stable_memory) { ++ code = alloc_save_change_alloc(mem, "gs_alloc_ref_array", &cp); ++ if (code < 0) ++ return code; ++ } + obj = gs_alloc_struct_array((gs_memory_t *) mem, num_refs + 1, + ref, &st_refs, cname); + if (obj == 0) +@@ -210,14 +217,10 @@ gs_alloc_ref_array(gs_ref_memory_t * mem + chunk_locate_ptr(obj, &cl); + cl.cp->has_refs = true; + } +- if ((gs_memory_t *)mem != mem->stable_memory) { +- ref_packed **ppr = 0; +- int code = alloc_save_change_alloc(mem, "gs_alloc_ref_array", &ppr); +- if (code < 0) +- return code; +- if (ppr) +- *ppr = (ref_packed *)obj; +- } ++ if (cp) { ++ mem->changes = cp; ++ cp->where = (ref_packed *)obj; ++ } + } + make_array(parr, attrs | mem->space, num_refs, obj); + return 0; +diff -up ghostscript-8.70/psi/idosave.h.CVE-2010-1628 ghostscript-8.70/psi/idosave.h +--- ghostscript-8.70/psi/idosave.h.CVE-2010-1628 2008-08-28 23:48:19.000000000 +0100 ++++ ghostscript-8.70/psi/idosave.h 2010-07-16 12:15:45.238073609 +0100 +@@ -18,6 +18,22 @@ + # define idosave_INCLUDED + + /* ++ * Structure for saved change chain for save/restore. Because of the ++ * garbage collector, we need to distinguish the cases where the change ++ * is in a static object, a dynamic ref, or a dynamic struct. ++ */ ++typedef struct alloc_change_s alloc_change_t; ++struct alloc_change_s { ++ alloc_change_t *next; ++ ref_packed *where; ++ ref contents; ++#define AC_OFFSET_STATIC (-2) /* static object */ ++#define AC_OFFSET_REF (-1) /* dynamic ref */ ++#define AC_OFFSET_ALLOCATED (-3) /* a newly allocated ref array */ ++ short offset; /* if >= 0, offset within struct */ ++}; ++ ++/* + * Save a change that must be undone by restore. We have to pass the + * pointer to the containing object to alloc_save_change for two reasons: + * +@@ -29,6 +45,7 @@ + * relocate the pointer to it from the change record during garbage + * collection. + */ ++ + int alloc_save_change(gs_dual_memory_t *dmem, const ref *pcont, + ref_packed *ptr, client_name_t cname); + int alloc_save_change_in(gs_ref_memory_t *mem, const ref *pcont, +@@ -36,6 +53,6 @@ int alloc_save_change_in(gs_ref_memory_t + /* Remove an AC_OFFSET_ALLOCATED element. */ + void alloc_save_remove(gs_ref_memory_t *mem, ref_packed *obj, client_name_t cname); + /* Allocate a structure for recording an allocation event. */ +-int alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr); ++int alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, alloc_change_t **pcp); + + #endif /* idosave_INCLUDED */ +diff -up ghostscript-8.70/psi/isave.c.CVE-2010-1628 ghostscript-8.70/psi/isave.c +--- ghostscript-8.70/psi/isave.c.CVE-2010-1628 2008-08-28 23:48:19.000000000 +0100 ++++ ghostscript-8.70/psi/isave.c 2010-07-16 12:15:45.245073557 +0100 +@@ -156,22 +156,6 @@ print_save(const char *str, uint spacen, + /* A link to igcref.c . */ + ptr_proc_reloc(igc_reloc_ref_ptr_nocheck, ref_packed); + +-/* +- * Structure for saved change chain for save/restore. Because of the +- * garbage collector, we need to distinguish the cases where the change +- * is in a static object, a dynamic ref, or a dynamic struct. +- */ +-typedef struct alloc_change_s alloc_change_t; +-struct alloc_change_s { +- alloc_change_t *next; +- ref_packed *where; +- ref contents; +-#define AC_OFFSET_STATIC (-2) /* static object */ +-#define AC_OFFSET_REF (-1) /* dynamic ref */ +-#define AC_OFFSET_ALLOCATED (-3) /* a newly allocated ref array */ +- short offset; /* if >= 0, offset within struct */ +-}; +- + static + CLEAR_MARKS_PROC(change_clear_marks) + { +@@ -519,7 +503,7 @@ alloc_save_change(gs_dual_memory_t * dme + + /* Allocate a structure for recording an allocation event. */ + int +-alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr) ++alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, alloc_change_t **pcp) + { + register alloc_change_t *cp; + +@@ -533,8 +517,7 @@ alloc_save_change_alloc(gs_ref_memory_t + cp->where = 0; + cp->offset = AC_OFFSET_ALLOCATED; + make_null(&cp->contents); +- mem->changes = cp; +- *ppr = &cp->where; ++ *pcp = cp; + return 1; + } + diff --git a/ghostscript.spec b/ghostscript.spec index 21f2db8..31db348 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 6%{?dist} +Release: 7%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -35,6 +35,7 @@ Patch16: ghostscript-cups-realloc-color-depth.patch Patch17: ghostscript-tif-fail-close.patch Patch18: ghostscript-tiff-default-strip-size.patch Patch19: ghostscript-tiff-fixes.patch +Patch20: ghostscript-CVE-2010-1628.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -164,6 +165,10 @@ rm -rf libpng zlib jpeg jasper # Backported some more TIFF fixes (bug #573970). %patch19 -p1 -b .tiff-fixes +# Applied patch to fix CVE-2010-1628 (memory corruption at PS stack +# overflow, bug #592492). +%patch20 -p1 -b .CVE-2010-1628 + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -352,6 +357,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Fri Jul 16 2010 Tim Waugh 8.71-7 +- Applied patch to fix CVE-2010-1628 (memory corruption at PS stack + overflow, bug #592492). + * Tue Mar 16 2010 Tim Waugh 8.71-6 - Backported some more TIFF fixes (bug #573970). - Use upstream fix for TIFF default strip size (bug #571520). From 4257a957f75c2783db7763a6b807ff02b1bb25a5 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 28 Jul 2010 15:36:44 +0000 Subject: [PATCH 19/19] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- branch | 1 - 3 files changed, 22 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile delete mode 100644 branch diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index ad9af45..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: ghostscript -# $Id: Makefile,v 1.2 2007/10/15 18:47:19 notting Exp $ -NAME := ghostscript -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attempt a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/branch b/branch deleted file mode 100644 index 06de2d2..0000000 --- a/branch +++ /dev/null @@ -1 +0,0 @@ -F-12