[arch-commits] Commit in ghostscript/repos (8 files)

Evangelos Foutras foutrelis at archlinux.org
Mon Sep 10 22:41:00 UTC 2018


    Date: Monday, September 10, 2018 @ 22:40:59
  Author: foutrelis
Revision: 334339

archrelease: copy trunk to staging-x86_64

Added:
  ghostscript/repos/staging-x86_64/
  ghostscript/repos/staging-x86_64/0001_ICC_profile_validation.patch
    (from rev 334337, ghostscript/trunk/0001_ICC_profile_validation.patch)
  ghostscript/repos/staging-x86_64/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch
    (from rev 334337, ghostscript/trunk/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch)
  ghostscript/repos/staging-x86_64/0003_Fix_SEGV_seen_in_all-devices_test.patch
    (from rev 334337, ghostscript/trunk/0003_Fix_SEGV_seen_in_all-devices_test.patch)
  ghostscript/repos/staging-x86_64/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch
    (from rev 334337, ghostscript/trunk/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch)
  ghostscript/repos/staging-x86_64/0005_add_wildcards_to_the_permissions_paths.patch
    (from rev 334337, ghostscript/trunk/0005_add_wildcards_to_the_permissions_paths.patch)
  ghostscript/repos/staging-x86_64/0006_stack_size_space_fix.patch
    (from rev 334337, ghostscript/trunk/0006_stack_size_space_fix.patch)
  ghostscript/repos/staging-x86_64/PKGBUILD
    (from rev 334337, ghostscript/trunk/PKGBUILD)

---------------------------------------------------------------------+
 0001_ICC_profile_validation.patch                                   |   80 +++
 0002_retain_LockSafetyParams_through_failed_installpagedevice.patch |   69 ++
 0003_Fix_SEGV_seen_in_all-devices_test.patch                        |   40 +
 0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch         |   43 +
 0005_add_wildcards_to_the_permissions_paths.patch                   |   55 ++
 0006_stack_size_space_fix.patch                                     |  254 ++++++++++
 PKGBUILD                                                            |  123 ++++
 7 files changed, 664 insertions(+)

Copied: ghostscript/repos/staging-x86_64/0001_ICC_profile_validation.patch (from rev 334337, ghostscript/trunk/0001_ICC_profile_validation.patch)
===================================================================
--- staging-x86_64/0001_ICC_profile_validation.patch	                        (rev 0)
+++ staging-x86_64/0001_ICC_profile_validation.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,80 @@
+From bc3df0773fccf4b4906a3e59652ad646ea0fee91 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Tue, 4 Sep 2018 17:01:08 +0100
+Subject: [PATCH] For ICC profile validation, have cups id iteself as DeviceN
+
+Give the range of color spaces and models that cups supports, we can't
+reasonably provide (or expect others to provide) output ICC profiles for all
+cases.
+
+For the purpose of profile validation, have it claim to be DeviceN and benefit
+from the extra tolerance in profiles allowed for that class of device.
+---
+ cups/gdevcups.c  | 15 ++++++++++++++-
+ devices/devs.mak |  2 +-
+ 2 files changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/cups/gdevcups.c b/cups/gdevcups.c
+index c1574f8..decd8eb 100644
+--- a/cups/gdevcups.c
++++ b/cups/gdevcups.c
+@@ -70,6 +70,7 @@
+ #include "std.h"                /* to stop stdlib.h redefining types */
+ #include "gdevprn.h"
+ #include "gsparam.h"
++#include "gxdevsop.h"
+ #include "arch.h"
+ #include "gsicc_manage.h"
+ 
+@@ -252,6 +253,7 @@ private int cups_put_params(gx_device *, gs_param_list *);
+ private int cups_set_color_info(gx_device *);
+ private dev_proc_sync_output(cups_sync_output);
+ private prn_dev_proc_get_space_params(cups_get_space_params);
++private int cups_spec_op(gx_device *dev_, int op, void *data, int datasize);
+ 
+ #ifdef dev_t_proc_encode_color
+ private cm_map_proc_gray(cups_map_gray);
+@@ -392,7 +394,7 @@ private gx_device_procs	cups_procs =
+    NULL,				/* push_transparency_state */
+    NULL,				/* pop_transparency_state */
+    NULL,                                /* put_image */
+-
++   cups_spec_op
+ };
+ 
+ #define prn_device_body_copies(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_pages)\
+@@ -5927,6 +5929,17 @@ cups_print_planar(gx_device_printer *pdev,
+   return (0);
+ }
+ 
++private int
++cups_spec_op(gx_device *dev_, int op, void *data, int datasize)
++{
++    /* Although not strictly DeviceN, the range of color models
++       this device supports presets similar issues.
++     */
++    if (op == gxdso_supports_devn) {
++        return true;
++    }
++    return gx_default_dev_spec_op(dev_, op, data, datasize);
++}
+ 
+ /*
+  */
+diff --git a/devices/devs.mak b/devices/devs.mak
+index c85604c..e8654e5 100644
+--- a/devices/devs.mak
++++ b/devices/devs.mak
+@@ -1860,7 +1860,7 @@ $(DD)pwgraster.dev : $(lcups_dev) $(lcupsi_dev) $(cups_) $(GDEV) \
+ 	$(ADDMOD) $(DD)pwgraster -include $(lcups_dev)
+ 	$(ADDMOD) $(DD)pwgraster -include $(lcupsi_dev)
+ 
+-$(DEVOBJ)gdevcups.$(OBJ) : $(LCUPSSRCDIR)$(D)gdevcups.c $(std_h) $(DEVS_MAK) $(MAKEDIRS)
++$(DEVOBJ)gdevcups.$(OBJ) : $(LCUPSSRCDIR)$(D)gdevcups.c $(std_h) $(gxdevsop_h) $(DEVS_MAK) $(MAKEDIRS)
+ 	$(CUPS_CC) $(DEVO_)gdevcups.$(OBJ) $(C_) $(CFLAGS) $(CUPSCFLAGS) \
+ 	    $(I_)$(GLSRC) \
+ 	    $(I_)$(DEVSRC) \
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch (from rev 334337, ghostscript/trunk/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch)
===================================================================
--- staging-x86_64/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch	                        (rev 0)
+++ staging-x86_64/0002_retain_LockSafetyParams_through_failed_installpagedevice.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,69 @@
+From 5812b1b78fc4d36fdc293b7859de69241140d590 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Tue, 4 Sep 2018 23:18:46 +0100
+Subject: [PATCH] Bug 699714: retain .LockSafetyParams through failed
+ .installpagedevice
+
+In the event that the .trysetparams fails during .installpagedevice, catch the
+error, and ensure that at least the .LockSafetyParams is set.
+---
+ Resource/Init/gs_setpd.ps | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
+index bba3c8c..aee9614 100644
+--- a/Resource/Init/gs_setpd.ps
++++ b/Resource/Init/gs_setpd.ps
+@@ -95,12 +95,19 @@ level2dict begin
+  {	% Since setpagedevice doesn't create new device objects,
+         % we must (carefully) reinstall the old parameters in
+         % the same device.
+-   .currentpagedevice pop //null currentdevice //null .trysetparams
++   .currentpagedevice pop //null currentdevice //null
++   {.trysetparams} .internalstopped
++   {
++     //null
++   } if
+    dup type /booleantype eq
+     { pop pop }
+-    {		% This should never happen!
++    {
+       SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if
+       cleartomark pop pop pop
++      % if resetting the entire device state failed, at least put back the se
++      currentdevice //null //false mark /.LockSafetyParams .currentpagedevice pop
++      /.LockSafetyParams .knownget not {//false} if .putdeviceparamsonly
+       /.installpagedevice cvx /rangecheck signalerror
+     }
+    ifelse pop pop
+-- 
+2.9.1
+
+
+From e914f1da46e33decc534486598dc3eadf69e6efb Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Wed, 5 Sep 2018 08:44:41 +0100
+Subject: [PATCH] Fix incomplete comment from previous commit
+
+---
+ Resource/Init/gs_setpd.ps | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
+index aee9614..b75c431 100644
+--- a/Resource/Init/gs_setpd.ps
++++ b/Resource/Init/gs_setpd.ps
+@@ -105,7 +105,8 @@ level2dict begin
+     {
+       SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if
+       cleartomark pop pop pop
+-      % if resetting the entire device state failed, at least put back the se
++      % if resetting the entire device state failed, at least put back the
++      % security related key
+       currentdevice //null //false mark /.LockSafetyParams .currentpagedevice pop
+       /.LockSafetyParams .knownget not {//false} if .putdeviceparamsonly
+       /.installpagedevice cvx /rangecheck signalerror
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/0003_Fix_SEGV_seen_in_all-devices_test.patch (from rev 334337, ghostscript/trunk/0003_Fix_SEGV_seen_in_all-devices_test.patch)
===================================================================
--- staging-x86_64/0003_Fix_SEGV_seen_in_all-devices_test.patch	                        (rev 0)
+++ staging-x86_64/0003_Fix_SEGV_seen_in_all-devices_test.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,40 @@
+From 68eca5e94e6f63f4392b15581ad41af52e0edfd9 Mon Sep 17 00:00:00 2001
+From: Robin Watts <robin.watts at artifex.com>
+Date: Thu, 6 Sep 2018 12:56:51 +0100
+Subject: [PATCH] Fix SEGV seen in all-devices test with plank
+ examples/ridt91.eps
+
+Silly typo in the contone fill code for the landscape flippedy
+color cache case.
+---
+ base/gximono.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/base/gximono.c b/base/gximono.c
+index 2971f40..276db69 100644
+--- a/base/gximono.c
++++ b/base/gximono.c
+@@ -1222,8 +1222,8 @@ image_render_mono_ht(gx_image_enum * penum_orig, const byte * buffer, int data_x
+                                 dev_value = &(color_cache[*psrc * spp_out]);
+                                 for (j = 0; j < spp_out; j++) {
+                                     *(devc_contone[j] + position) = dev_value[j];
+-                                    position -= LAND_BITS;
+                                 }
++                                position -= LAND_BITS;
+                                 xr--;
+                             }           /* at loop exit xn will be <= xr */
+                             psrc++;
+@@ -1259,8 +1259,8 @@ image_render_mono_ht(gx_image_enum * penum_orig, const byte * buffer, int data_x
+                                 dev_value = &(color_cache[*psrc * spp_out]);
+                                 for (j = 0; j < spp_out; j++) {
+                                     *(devc_contone[j] + position) = dev_value[j];
+-                                    devc_contone[j] += LAND_BITS;
+                                 }
++                                position += LAND_BITS;
+                                 xr++;
+                             }           /* at loop exit xn will be >= xr */
+                             psrc++;
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch (from rev 334337, ghostscript/trunk/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch)
===================================================================
--- staging-x86_64/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch	                        (rev 0)
+++ staging-x86_64/0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,43 @@
+From c8c01f8c4164bc10281d9e8f87cf96314d93104b Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Thu, 6 Sep 2018 14:08:41 +0100
+Subject: [PATCH] Bug 699722: Add the ICCProfilesDir to the PermitReading list
+
+There was also an issue that the string being returned from the graphics
+library was null terminated, and Postscript strings are not (and Ghostscript
+strings are not necessarily). We leave the null termination in place, but
+reduce the length returned by 1.
+---
+ Resource/Init/gs_init.ps | 1 +
+ base/gsicc_manage.c      | 2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
+index bc8b795..83918a9 100644
+--- a/Resource/Init/gs_init.ps
++++ b/Resource/Init/gs_init.ps
+@@ -2049,6 +2049,7 @@ readonly def
+           [ currentsystemparams /GenericResourceDir get] (*) .file_name_separator (*)
+             concatstrings concatstrings .generate_dir_list_templates
+         } if
++        currentuserparams /ICCProfilesDir known {currentuserparams /ICCProfilesDir get} if
+       ]
+       /PermitFileWriting [
+           currentuserparams /PermitFileWriting get aload pop
+diff --git a/base/gsicc_manage.c b/base/gsicc_manage.c
+index 69f05c4..ff685e7 100644
+--- a/base/gsicc_manage.c
++++ b/base/gsicc_manage.c
+@@ -2972,7 +2972,7 @@ gs_currenticcdirectory(const gs_gstate * pgs, gs_param_string * pval)
+         pval->persistent = true;
+     } else {
+         pval->data = (const byte *)(lib_ctx->profiledir);
+-        pval->size = lib_ctx->profiledir_len;
++        pval->size = lib_ctx->profiledir_len - 1;
+         pval->persistent = false;
+     }
+ }
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/0005_add_wildcards_to_the_permissions_paths.patch (from rev 334337, ghostscript/trunk/0005_add_wildcards_to_the_permissions_paths.patch)
===================================================================
--- staging-x86_64/0005_add_wildcards_to_the_permissions_paths.patch	                        (rev 0)
+++ staging-x86_64/0005_add_wildcards_to_the_permissions_paths.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,55 @@
+From 13418541a5ae19b15f51cbb87faf344902f5af98 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Thu, 6 Sep 2018 18:40:05 +0100
+Subject: [PATCH] Bug 699722 (2): add wildcards to the permissions paths.
+
+The temp and ICC profile paths need to finish with wildcards to work correctly.
+---
+ Resource/Init/gs_init.ps | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
+index 83918a9..5ff9f63 100644
+--- a/Resource/Init/gs_init.ps
++++ b/Resource/Init/gs_init.ps
+@@ -2034,7 +2034,7 @@ readonly def
+     <<
+       /PermitFileReading [
+         currentuserparams /PermitFileReading get aload pop
+-        //tempfilepaths aload pop
++        [//tempfilepaths aload pop] (*) .generate_dir_list_templates
+         /FONTPATH .systemvar (*) .generate_dir_list_templates
+           % Library files :
+         /LIBPATH  .systemvar (*) .generate_dir_list_templates
+@@ -2049,15 +2049,15 @@ readonly def
+           [ currentsystemparams /GenericResourceDir get] (*) .file_name_separator (*)
+             concatstrings concatstrings .generate_dir_list_templates
+         } if
+-        currentuserparams /ICCProfilesDir known {currentuserparams /ICCProfilesDir get} if
++        currentuserparams /ICCProfilesDir known {[currentuserparams /ICCProfilesDir get] (*) .generate_dir_list_templates} if
+       ]
+       /PermitFileWriting [
+           currentuserparams /PermitFileWriting get aload pop
+-          //tempfilepaths aload pop
++          [//tempfilepaths aload pop] (*) .generate_dir_list_templates
+       ]
+       /PermitFileControl [
+           currentuserparams /PermitFileControl get aload pop
+-          //tempfilepaths aload pop
++          [//tempfilepaths aload pop] (*) .generate_dir_list_templates
+       ]
+       /LockFilePermissions //true
+     >> setuserparams
+@@ -2140,7 +2140,7 @@ SAFER { .setsafeglobal } if
+   /.setshapealpha            % transparency-example.ps
+   /.endtransparencygroup     % transparency-example.ps
+   /.setdotlength             % Bug687720.ps
+-  /.sort /.setdebug /.mementolistnewblocks /getenv
++  /.sort /.mementolistnewblocks /getenv
+ 
+   /.makeoperator /.setCPSImode              % gs_cet.ps, this won't work on cluster with -dSAFER
+ 
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/0006_stack_size_space_fix.patch (from rev 334337, ghostscript/trunk/0006_stack_size_space_fix.patch)
===================================================================
--- staging-x86_64/0006_stack_size_space_fix.patch	                        (rev 0)
+++ staging-x86_64/0006_stack_size_space_fix.patch	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,254 @@
+From 3e5d316b72e3965b7968bb1d96baa137cd063ac6 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Wed, 5 Sep 2018 17:14:59 +0100
+Subject: [PATCH] Bug 699718: Ensure stack space is available before gsrestore
+ call out
+
+During a grestore, if the device is going to change, we call out to Postscript
+to restore the device configuration, before returning to restore the graphics
+state internally.
+
+We have to ensure sufficient op stack space is available to complete the
+operation, otherwise the device can end up an undefined state.
+---
+ Resource/Init/gs_setpd.ps | 20 +++++++++++------
+ psi/zdevice2.c            | 55 ++++++++++++++++++++++++++++++++++++-----------
+ 2 files changed, 56 insertions(+), 19 deletions(-)
+
+diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
+index b75c431..8fa7c51 100644
+--- a/Resource/Init/gs_setpd.ps
++++ b/Resource/Init/gs_setpd.ps
+@@ -96,7 +96,7 @@ level2dict begin
+         % we must (carefully) reinstall the old parameters in
+         % the same device.
+    .currentpagedevice pop //null currentdevice //null
+-   {.trysetparams} .internalstopped
++   { .trysetparams } .internalstopped
+    {
+      //null
+    } if
+@@ -104,26 +104,32 @@ level2dict begin
+     { pop pop }
+     {
+       SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if
+-      cleartomark pop pop pop
++      {cleartomark pop pop pop} .internalstopped pop
+       % if resetting the entire device state failed, at least put back the
+       % security related key
+-      currentdevice //null //false mark /.LockSafetyParams .currentpagedevice pop
+-      /.LockSafetyParams .knownget not {//false} if .putdeviceparamsonly
++      currentdevice //null //false mark /.LockSafetyParams
++      currentpagedevice /.LockSafetyParams .knownget not
++      {systemdict /SAFER .knownget not {//false} } if
++      .putdeviceparamsonly
+       /.installpagedevice cvx /rangecheck signalerror
+     }
+    ifelse pop pop
+         % A careful reading of the Red Book reveals that an erasepage
+         % should occur, but *not* an initgraphics.
+    erasepage .beginpage
+- } bind def
++ } bind executeonly def
+ 
+ /.uninstallpagedevice
+- { 2 .endpage { .currentnumcopies //false .outputpage } if
++ {
++   {2 .endpage { .currentnumcopies //false .outputpage } if} .internalstopped pop
+    nulldevice
+  } bind def
+ 
+ (%grestorepagedevice) cvn
+- { .uninstallpagedevice grestore .installpagedevice
++ {
++ .uninstallpagedevice
++ grestore
++ .installpagedevice
+  } bind def
+ 
+ (%grestoreallpagedevice) cvn
+diff --git a/psi/zdevice2.c b/psi/zdevice2.c
+index 0c7080d..5447c8c 100644
+--- a/psi/zdevice2.c
++++ b/psi/zdevice2.c
+@@ -251,8 +251,8 @@ z2currentgstate(i_ctx_t *i_ctx_p)
+ /* ------ Wrappers for operators that reset the graphics state. ------ */
+ 
+ /* Check whether we need to call out to restore the page device. */
+-static bool
+-restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
++static int
++restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate * pgs_new)
+ {
+     gx_device *dev_old = gs_currentdevice(pgs_old);
+     gx_device *dev_new;
+@@ -260,9 +260,10 @@ restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
+     gx_device *dev_t2;
+     bool samepagedevice = obj_eq(dev_old->memory, &gs_int_gstate(pgs_old)->pagedevice,
+         &gs_int_gstate(pgs_new)->pagedevice);
++    bool LockSafetyParams = dev_old->LockSafetyParams;
+ 
+     if ((dev_t1 = (*dev_proc(dev_old, get_page_device)) (dev_old)) == 0)
+-        return false;
++        return 0;
+     /* If we are going to putdeviceparams in a callout, we need to */
+     /* unlock temporarily.  The device will be re-locked as needed */
+     /* by putdeviceparams from the pgs_old->pagedevice dict state. */
+@@ -271,23 +272,44 @@ restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
+     dev_new = gs_currentdevice(pgs_new);
+     if (dev_old != dev_new) {
+         if ((dev_t2 = (*dev_proc(dev_new, get_page_device)) (dev_new)) == 0)
+-            return false;
+-        if (dev_t1 != dev_t2)
+-            return true;
++            samepagedevice = true;
++        else if (dev_t1 != dev_t2)
++            samepagedevice = false;
++    }
++
++    if (LockSafetyParams && !samepagedevice) {
++        os_ptr op = osp;
++        const int max_ops = 512;
++
++        /* The %grestorepagedevice must complete: the biggest danger
++           is operand stack overflow. As we use get/putdeviceparams
++           that means pushing all the device params onto the stack,
++           pdfwrite having by far the largest number of parameters
++           at (currently) 212 key/value pairs - thus needing (currently)
++           424 entries on the op stack. Allowing for working stack
++           space, and safety margin.....
++         */
++        if (max_ops > op - osbot) {
++            if (max_ops >= ref_stack_count(&o_stack))
++               return_error(gs_error_stackoverflow);
++        }
+     }
+     /*
+      * The current implementation of setpagedevice just sets new
+      * parameters in the same device object, so we have to check
+      * whether the page device dictionaries are the same.
+      */
+-    return !samepagedevice;
++    return samepagedevice ? 0 : 1;
+ }
+ 
+ /* - grestore - */
+ static int
+ z2grestore(i_ctx_t *i_ctx_p)
+ {
+-    if (!restore_page_device(igs, gs_gstate_saved(igs)))
++    int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
++    if (code < 0) return code;
++
++    if (code == 0)
+         return gs_grestore(igs);
+     return push_callout(i_ctx_p, "%grestorepagedevice");
+ }
+@@ -297,7 +319,9 @@ static int
+ z2grestoreall(i_ctx_t *i_ctx_p)
+ {
+     for (;;) {
+-        if (!restore_page_device(igs, gs_gstate_saved(igs))) {
++        int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
++        if (code < 0) return code;
++        if (code == 0) {
+             bool done = !gs_gstate_saved(gs_gstate_saved(igs));
+ 
+             gs_grestore(igs);
+@@ -328,11 +352,15 @@ z2restore(i_ctx_t *i_ctx_p)
+     if (code < 0) return code;
+ 
+     while (gs_gstate_saved(gs_gstate_saved(igs))) {
+-        if (restore_page_device(igs, gs_gstate_saved(igs)))
++        code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
++        if (code < 0) return code;
++        if (code > 0)
+             return push_callout(i_ctx_p, "%restore1pagedevice");
+         gs_grestore(igs);
+     }
+-    if (restore_page_device(igs, gs_gstate_saved(igs)))
++    code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
++    if (code < 0) return code;
++    if (code > 0)
+         return push_callout(i_ctx_p, "%restorepagedevice");
+ 
+     code = dorestore(i_ctx_p, asave);
+@@ -355,9 +383,12 @@ static int
+ z2setgstate(i_ctx_t *i_ctx_p)
+ {
+     os_ptr op = osp;
++    int code;
+ 
+     check_stype(*op, st_igstate_obj);
+-    if (!restore_page_device(igs, igstate_ptr(op)))
++    code = restore_page_device(i_ctx_p, igs, igstate_ptr(op));
++    if (code < 0) return code;
++    if (code == 0)
+         return zsetgstate(i_ctx_p);
+     return push_callout(i_ctx_p, "%setgstatepagedevice");
+ }
+-- 
+2.9.1
+
+From 643b24dbd002fb9c131313253c307cf3951b3d47 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell at artifex.com>
+Date: Fri, 7 Sep 2018 08:07:12 +0100
+Subject: [PATCH] Bug 699718(2): Improve/augment stack size checking
+
+Improve the rebustness of the previous solution (previously it could trigger an
+error when there *was* stack capacity available).
+
+Remove redundant check: we don't need to check if the *current* stack size is
+sufficient, before checking the maximum permitted stack size.
+
+Also check the exec stack, as execstackoverflow can also cause the
+Postscript call out to fail.
+
+Lastly, in event of failure, put the LockSafetyParams flag back in the existing
+device (this is only necessary because we don't enfore JOBSERVER mode).
+
+Note: the Postscript callout (%grestorepagedevice) never pushes any dictionaries
+on the dict stack - if that changes, we should check that stack, too.
+---
+ psi/zdevice2.c | 17 ++++++++++++-----
+ 1 file changed, 12 insertions(+), 5 deletions(-)
+
+diff --git a/psi/zdevice2.c b/psi/zdevice2.c
+index 5447c8c..159a0c0 100644
+--- a/psi/zdevice2.c
++++ b/psi/zdevice2.c
+@@ -278,8 +278,8 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
+     }
+ 
+     if (LockSafetyParams && !samepagedevice) {
+-        os_ptr op = osp;
+-        const int max_ops = 512;
++        const int required_ops = 512;
++        const int required_es = 32;
+ 
+         /* The %grestorepagedevice must complete: the biggest danger
+            is operand stack overflow. As we use get/putdeviceparams
+@@ -289,9 +289,16 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
+            424 entries on the op stack. Allowing for working stack
+            space, and safety margin.....
+          */
+-        if (max_ops > op - osbot) {
+-            if (max_ops >= ref_stack_count(&o_stack))
+-               return_error(gs_error_stackoverflow);
++        if (required_ops + ref_stack_count(&o_stack) >= ref_stack_max_count(&o_stack)) {
++           gs_currentdevice(pgs_old)->LockSafetyParams = LockSafetyParams;
++           return_error(gs_error_stackoverflow);
++        }
++        /* We also want enough exec stack space - 32 is an overestimate of
++           what we need to complete the Postscript call out.
++         */
++        if (required_es + ref_stack_count(&e_stack) >= ref_stack_max_count(&e_stack)) {
++           gs_currentdevice(pgs_old)->LockSafetyParams = LockSafetyParams;
++           return_error(gs_error_execstackoverflow);
+         }
+     }
+     /*
+-- 
+2.9.1
+
+

Copied: ghostscript/repos/staging-x86_64/PKGBUILD (from rev 334337, ghostscript/trunk/PKGBUILD)
===================================================================
--- staging-x86_64/PKGBUILD	                        (rev 0)
+++ staging-x86_64/PKGBUILD	2018-09-10 22:40:59 UTC (rev 334339)
@@ -0,0 +1,123 @@
+# $Id$
+# Maintainer: AndyRTR <andyrtr at archlinux.org>
+
+pkgbase=ghostscript
+pkgname=(ghostscript ghostxps ghostpcl)
+pkgver=9.24
+pkgrel=7
+pkgdesc="An interpreter for the PostScript language"
+url="https://www.ghostscript.com/"
+arch=('x86_64')
+license=('AGPL3' 'custom')
+depends=('libxt' 'libcups' 'fontconfig' 'zlib' 'libpng' 'libjpeg' 'jbig2dec'
+         'libtiff' 'lcms2' 'dbus' 'libpaper' 'ijs' 'openjpeg2')
+makedepends=('gtk3' 'gnutls' 'glu' 'freeglut')
+# https://github.com/ArtifexSoftware/ghostpdl-downloads/releases
+source=(https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${pkgver/./}/ghostpdl-${pkgver}.tar.gz
+       0001_ICC_profile_validation.patch
+       0002_retain_LockSafetyParams_through_failed_installpagedevice.patch
+       0003_Fix_SEGV_seen_in_all-devices_test.patch
+       0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch
+       0005_add_wildcards_to_the_permissions_paths.patch
+       0006_stack_size_space_fix.patch)
+sha512sums=('a0ed7235808ed79ad88ddf0808ef3eb667ffd1b0300ceda78eac3d0ad69d4a963821fa05319ed822db51911210c4fd7d8dbd4d73951e330fbc7b99e4f00a45fa'
+            '6cfdd351e8e84968c20cf8f15e01a09a215b6132af89ca0e392716638d925a0f750dab3dbcbdf44f200fb9cc419be5dadccffc226c9a405e888f3580f98cf4ea'
+            '670ccf36927904fc2e918847baf082753d3b4b81fd0ee2347feb6de5a0ab77eb9c00cb640fcb3c7a0f395694112f3921775a6f614bec08e3d4452155b030951e'
+            '45be77dc890d9d251541d44fe0ad860a7d83d969ce697bbb32cb469d8837417020f1a017ae7aecbb8fbb45647ad9c3e6f92d321c2adfe6c8b3412c580f4058c5'
+            'e64bcf8e5b5f229ca14463477be21555e66a0f3c76e3c01eb9b4d8cbeebba683b9b33a624ac4617af715c281f93106ae5d8425a29ed35416fbd580242a1a27e0'
+            '52088ef6ca47c5ed6f34ccac2b5234bcd6561175ef35de90ede7322a98e617b37036bf8a092733bec11fea211c7e3806b98c4019b1a806f6616387ee48002ef3'
+            '4a09455d2e844cf1e8fc91fdfda5e1dd9160dd0a49bad4b1baea186d858bbdaa01980c81022c8f9fb209c329a3668575c47d879cc44db36df6a39bc86eab0928')
+
+prepare() {
+  cd ghostpdl-${pkgver}
+
+  # force it to use system-libs
+  rm -r cups/libs expat ijs jbig2dec jpeg lcms2mt libpng openjpeg tiff zlib
+  # using tree freetype because of https://bugs.archlinux.org/task/56849
+  # lcms2mt is the new lcms2 fork aimed to replace lcms2 in a thread safe way
+
+  # https://bugs.ghostscript.com/show_bug.cgi?id=699713
+  patch -Np1 -i ../0001_ICC_profile_validation.patch
+  # apply more upstream fixes to solve various crashes
+  patch -Np1 -i ../0002_retain_LockSafetyParams_through_failed_installpagedevice.patch
+  patch -Np1 -i ../0003_Fix_SEGV_seen_in_all-devices_test.patch
+  # FS#59952;FS#59959
+  patch -Np1 -i ../0004_Add_the_ICCProfilesDir_to_the_PermitReading_list.patch
+  patch -Np1 -i ../0005_add_wildcards_to_the_permissions_paths.patch
+  # FS#59982
+  patch -Np1 -i ../0006_stack_size_space_fix.patch
+}
+
+build() {
+  cd ghostpdl-${pkgver}
+
+  ./configure --prefix=/usr \
+              --enable-dynamic \
+              --with-ijs \
+              --with-jbig2dec \
+              --with-x \
+              --with-drivers=ALL \
+              --with-fontpath=/usr/share/fonts/gsfonts \
+              --enable-fontconfig \
+              --enable-freetype \
+              --enable-openjpeg \
+              --without-luratech \
+              --with-system-libtiff \
+              --with-libpaper \
+              --disable-compile-inits #--help # needed for linking with system-zlib
+
+  make so-only
+}
+
+package_ghostscript() {
+  optdepends=('texlive-core:      needed for dvipdf'
+              'gtk3:              needed for gsx')
+
+  cd ghostpdl-${pkgver}
+
+  make DESTDIR="${pkgdir}" \
+       CUPSSERVERROOT="${pkgdir}$(cups-config --serverroot)" \
+       CUPSSERVERBIN="${pkgdir}$(cups-config --serverbin)" \
+       soinstall
+  ln -s gsc "${pkgdir}"/usr/bin/gs
+
+  # remove useless broken doc/ symlink - FS#59507
+  rm -f "${pkgdir}"/usr/share/ghostscript/${pkgver}/doc
+
+  # remove unwanted localized manpages
+  rm -r "${pkgdir}"/usr/share/man/de
+
+  install -Dt "${pkgdir}"/usr/share/licenses/${pkgname} -m644 LICENSE
+
+  rm "${pkgdir}"/usr/share/ghostscript/9.24/Resource/Init/gs_init.ps.orig
+}
+
+package_ghostxps() {
+  pkgdesc="${pkgdesc/PostScript/XPS document}"
+  depends=("ghostscript=${pkgver}-${pkgrel}")
+
+  cd ghostpdl-${pkgver}
+
+  install -Dt "${pkgdir}"/usr/bin sobin/gxpsc
+  ln -s gxpsc "${pkgdir}"/usr/bin/gxps
+
+  install -Dt "${pkgdir}"/usr/lib sobin/libgxps.so.${pkgver%.*}
+  ln -s libgxps.so.${pkgver%.*} "${pkgdir}"/usr/lib/libgxps.so.${pkgver%rc*}
+
+  install -Dt "${pkgdir}"/usr/share/licenses/${pkgname} -m644 LICENSE
+}
+
+package_ghostpcl() {
+  pkgdesc="${pkgdesc/PostScript/PCL 6}"
+  depends=("ghostscript=${pkgver}-${pkgrel}")
+
+  cd ghostpdl-${pkgver}
+
+  install -Dt "${pkgdir}"/usr/bin sobin/gpcl6c
+  ln -sf gpcl6c "${pkgdir}"/usr/bin/gpcl6
+
+  install -Dt "${pkgdir}"/usr/lib sobin/libgpcl6.so.${pkgver%.*}
+  ln -s libgpcl6.so.${pkgver%.*} "${pkgdir}"/usr/lib/libgpcl6.so.${pkgver%rc*}
+
+  install -Dt "${pkgdir}"/usr/share/licenses/${pkgname} -m644 LICENSE
+}



More information about the arch-commits mailing list