Blame SOURCES/ghostscript-cve-2019-3839.patch

483aca
From 95aa78beae9489d5c9f898fe2032aa23f860867d Mon Sep 17 00:00:00 2001
483aca
From: Ray Johnston <ray.johnston@artifex.com>
483aca
Date: Fri, 21 Sep 2018 11:16:18 -0700
483aca
Subject: [PATCH 1/6] Catch errors in setpagesize, .setpagesize and
483aca
 setpagedevice and cleanup
483aca
483aca
Bug 699794 showed that attempt to change page size in SAFER mode when the
483aca
nulldevice was the currentdevice would leave 'false' on the stack. Run
483aca
.setdevice in stopped and clean up, and also clean up .setpagesize
483aca
---
483aca
 Resource/Init/gs_lev2.ps  |  9 ++++++++-
483aca
 Resource/Init/gs_setpd.ps |  9 +++++++--
483aca
 Resource/Init/gs_statd.ps | 22 ++++++++++++++++++----
483aca
 3 files changed, 33 insertions(+), 7 deletions(-)
483aca
483aca
diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
483aca
index b69303d..ab0c32e 100644
483aca
--- a/Resource/Init/gs_lev2.ps
483aca
+++ b/Resource/Init/gs_lev2.ps
483aca
@@ -616,7 +616,14 @@ currentuserparams /WaitTimeout known
483aca
    .dicttomark setpagedevice
483aca
    /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams
483aca
  } bind def
483aca
-/.setpagesize { 2 array astore /PageSize .dict1 setpagedevice } bind def
483aca
+/.setpagesize
483aca
+ { 2 copy 2 array astore /PageSize .dict1 { setpagedevice } stopped {
483aca
+     pop	% the setpagedevice dict
483aca
+     /setpagesize $error /errorname get signalerror
483aca
+   } {
483aca
+     pop pop	% success -- pop the arguments
483aca
+   } ifelse
483aca
+ } bind def
483aca
 /setduplexmode { /Duplex .dict1 setpagedevice } bind def
483aca
 /setmargins
483aca
  { exch 2 array astore /Margins .dict1 setpagedevice
483aca
diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
483aca
index 46e5810..7875d1f 100644
483aca
--- a/Resource/Init/gs_setpd.ps
483aca
+++ b/Resource/Init/gs_setpd.ps
483aca
@@ -932,10 +932,15 @@ SETPDDEBUG { (Recovering.) = pstack flush } if
483aca
                 % Stack: mark ... <merged> <failed> <device> <eraseflag>
483aca
 SETPDDEBUG { (Installing.) = pstack flush } if
483aca
 
483aca
-    pop
483aca
+   pop
483aca
                 % .setdevice clears the current page device!
483aca
    .currentpagedevice pop exch
483aca
-   .setdevice pop
483aca
+   { .setdevice } stopped {
483aca
+     cleartomark exch pop
483aca
+     /setpagedevice $error /errorname get
483aca
+     signalerror
483aca
+   } if
483aca
+   pop
483aca
    .setpagedevice
483aca
 
483aca
                 % Implement UseCIEColor directly if this is a LL3 system.
483aca
diff --git a/Resource/Init/gs_statd.ps b/Resource/Init/gs_statd.ps
483aca
index 64c6463..34b759c 100644
483aca
--- a/Resource/Init/gs_statd.ps
483aca
+++ b/Resource/Init/gs_statd.ps
483aca
@@ -39,7 +39,13 @@ statusdict begin
483aca
 % These procedures are also accessed as data structures during initialization,
483aca
 % so the page dimensions must be the first two elements of the procedure.
483aca
 
483aca
-/.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
483aca
+/.setpagesize {
483aca
+   /statusdict .systemvar begin
483aca
+   { .setpagesize } stopped {
483aca
+     /setpagesize $error /errorname get signalerror
483aca
+   } if
483aca
+   end
483aca
+} bind def
483aca
 
483aca
                 % Page sizes defined by Adobe documentation
483aca
                 % Note: these executable arrays should all begin with two
483aca
@@ -261,9 +267,17 @@ readonly def
483aca
                 % The Adobe documentation only defines setpagetype
483aca
                 % (a Level 1 operator) as accepting the values 0 and 1,
483aca
                 % so we do too.
483aca
-      {/letter /note} 1 index get
483aca
-      //systemdict /userdict get exch get cvx exec
483aca
-      /pagetype exch def
483aca
+      dup type /integertype ne {
483aca
+        /setpage /typecheck signalerror
483aca
+      } {
483aca
+        dup 0 ne 1 index 1 ne or {
483aca
+          /setpage /rangecheck signalerror
483aca
+        } {
483aca
+          {/letter /note} 1 index get
483aca
+          //systemdict /userdict get exch get cvx exec
483aca
+        } ifelse
483aca
+        /pagetype exch def
483aca
+    } ifelse
483aca
     end
483aca
   } bind def
483aca
 
483aca
-- 
483aca
2.20.1
483aca
483aca
483aca
From c29ec2fff76e45bbf9cd767ff541556c5d064be4 Mon Sep 17 00:00:00 2001
483aca
From: Ray Johnston <ray.johnston@artifex.com>
483aca
Date: Fri, 21 Sep 2018 12:00:50 -0700
483aca
Subject: [PATCH 2/6] Add parameter checking in setresolution
483aca
483aca
Found in sequence for bug 699794
483aca
---
483aca
 Resource/Init/gs_lev2.ps | 9 ++++++++-
483aca
 1 file changed, 8 insertions(+), 1 deletion(-)
483aca
483aca
diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
483aca
index ab0c32e..0f0d573 100644
483aca
--- a/Resource/Init/gs_lev2.ps
483aca
+++ b/Resource/Init/gs_lev2.ps
483aca
@@ -637,7 +637,14 @@ currentuserparams /WaitTimeout known
483aca
    .dicttomark setpagedevice
483aca
  } bind def
483aca
 /setresolution
483aca
- { dup 2 array astore /HWResolution .dict1 setpagedevice
483aca
+ { count 1 lt { /setresolution /stackunderflow signalerror } if
483aca
+   dup type dup /integertype eq exch /realtype eq or not
483aca
+   {
483aca
+      /setresolution /typecheck signalerror
483aca
+   } if
483aca
+   dup 2 array astore /HWResolution .dict1 { setpagedevice } stopped {
483aca
+     pop /setresolution $error /errorname get signalerror
483aca
+   } if
483aca
  } bind def
483aca
 %END PAGEDEVICE
483aca
 
483aca
-- 
483aca
2.20.1
483aca
483aca
483aca
From fe4c47d8e25d6366ecbb5ff487348148b908a89e Mon Sep 17 00:00:00 2001
483aca
From: Nancy Durgin <nancy.durgin@artifex.com>
483aca
Date: Tue, 13 Nov 2018 14:23:41 -0800
483aca
Subject: [PATCH 3/6] Undefine some level2-related operators
483aca
483aca
These are only a partial set.  Undefine them in both the level2dict and
483aca
systemdict.  They are undef'd in gs_init.ps because they are used outside
483aca
the scope of just gs_lev2.ps
483aca
483aca
      /.execform1
483aca
      /.getdevparams
483aca
      /.setuserparams2
483aca
      /.startjob
483aca
      /.checkFilePermitparams
483aca
      /.checksetparams
483aca
      /.copyparam
483aca
      /.setpagesize
483aca
483aca
Rename .dict1 to .pair2dict and use immediate reference.
483aca
483aca
Undef these at end of gs_lev2.ps (should never make it into systemdict):
483aca
      /.pair2dict
483aca
      /.checkprocesscomment
483aca
---
483aca
 Resource/Init/gs_init.ps | 18 ++++++++++++++++++
483aca
 Resource/Init/gs_lev2.ps | 34 +++++++++++++++++++++-------------
483aca
 2 files changed, 39 insertions(+), 13 deletions(-)
483aca
483aca
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
483aca
index 48bb96d..e915f11 100644
483aca
--- a/Resource/Init/gs_init.ps
483aca
+++ b/Resource/Init/gs_init.ps
483aca
@@ -2271,6 +2271,24 @@ SAFER { .setsafeglobal } if
483aca
   ]
483aca
   {systemdict exch .forceundef} forall
483aca
 
483aca
+  % level 2 operators, undefine from both systemdict and level2dict
483aca
+  [
483aca
+      /.execform1
483aca
+      /.getdevparams
483aca
+      /.setuserparams2
483aca
+      /.startjob
483aca
+      /.checkFilePermitparams
483aca
+      /.checksetparams
483aca
+      /.copyparam
483aca
+      /.setpagesize
483aca
+
483aca
+% Couldn't figure out how to do these yet
483aca
+%      /.checkparamtype
483aca
+%      /.startnewjob
483aca
+  ]
483aca
+  dup {level2dict exch .forceundef} forall
483aca
+  {systemdict exch .forceundef} forall
483aca
+
483aca
   //systemdict /UndefinePostScriptOperators .forceundef
483aca
 } .bind executeonly def % must be bound and hidden for .forceundef
483aca
 
483aca
diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
483aca
index 0f0d573..e6f0645 100644
483aca
--- a/Resource/Init/gs_lev2.ps
483aca
+++ b/Resource/Init/gs_lev2.ps
483aca
@@ -64,7 +64,7 @@ level2dict begin
483aca
       pop
483aca
     } ifelse pop pop
483aca
   } forall pop pop
483aca
-} .bind def	% not odef, shouldn't reset stacks
483aca
+} .bind odef
483aca
 
483aca
 % currentuser/systemparams creates and returns a dictionary in the
483aca
 % current VM.  The easiest way to make this work is to copy any composite
483aca
@@ -101,7 +101,7 @@ level2dict begin
483aca
     1 index length string exch .setglobal
483aca
     copy exch not { readonly } if
483aca
   } if
483aca
-} .bind def
483aca
+} .bind odef
483aca
 
483aca
 % Some user parameters are managed entirely at the PostScript level.
483aca
 % We take care of that here.
483aca
@@ -345,13 +345,13 @@ end
483aca
   } ifelse
483aca
 } .bind def
483aca
 /ProcessComment //null .definepsuserparam
483aca
-psuserparams /ProcessComment {.checkprocesscomment} put
483aca
+psuserparams /ProcessComment {//.checkprocesscomment exec} put
483aca
 (%ProcessComment) cvn {
483aca
   /ProcessComment getuserparam
483aca
   dup //null eq { pop pop pop } { exec } ifelse
483aca
 } bind def
483aca
 /ProcessDSCComment //null .definepsuserparam
483aca
-psuserparams /ProcessDSCComment {.checkprocesscomment} put
483aca
+psuserparams /ProcessDSCComment {//.checkprocesscomment exec} put
483aca
 /.loadingfont //false def
483aca
 (%ProcessDSCComment) cvn {
483aca
   /ProcessDSCComment getuserparam
483aca
@@ -556,7 +556,8 @@ end		% serverdict
483aca
 % Note that statusdict must be allocated in local VM.
483aca
 % We don't bother with many of these yet.
483aca
 
483aca
-/.dict1 { exch mark 3 1 roll .dicttomark } bind def
483aca
+% convenience function to make a dictionary from an object and a key
483aca
+/.pair2dict { exch mark 3 1 roll .dicttomark } bind def
483aca
 
483aca
 currentglobal //false setglobal 25 dict exch setglobal begin
483aca
 currentsystemparams
483aca
@@ -569,11 +570,11 @@ systemdict /buildtime dup load put
483aca
 /checkpassword { .checkpassword 0 gt } bind def
483aca
 dup /DoStartPage known
483aca
  { /dostartpage { /DoStartPage getsystemparam } bind def
483aca
-   /setdostartpage { /DoStartPage .dict1 setsystemparams } bind def
483aca
+   /setdostartpage { /DoStartPage //.pair2dict exec setsystemparams } bind def
483aca
  } if
483aca
 dup /StartupMode known
483aca
  { /dosysstart { /StartupMode getsystemparam 0 ne } bind def
483aca
-   /setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def
483aca
+   /setdosysstart { { 1 } { 0 } ifelse /StartupMode //.pair2dict exec setsystemparams } bind def
483aca
  } if
483aca
 %****** Setting jobname is supposed to set userparams.JobName, too.
483aca
 /jobname { /JobName getuserparam } bind def
483aca
@@ -581,7 +582,7 @@ dup /StartupMode known
483aca
 /ramsize { /RamSize getsystemparam } bind def
483aca
 /realformat 1 index /RealFormat get def
483aca
 dup /PrinterName known
483aca
- { /setprintername { /PrinterName .dict1 setsystemparams } bind def
483aca
+ { /setprintername { /PrinterName //.pair2dict exec setsystemparams } bind def
483aca
  } if
483aca
 /printername
483aca
  { currentsystemparams /PrinterName .knownget not { () } if exch copy
483aca
@@ -617,18 +618,18 @@ currentuserparams /WaitTimeout known
483aca
    /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams
483aca
  } bind def
483aca
 /.setpagesize
483aca
- { 2 copy 2 array astore /PageSize .dict1 { setpagedevice } stopped {
483aca
+ { 2 copy 2 array astore /PageSize //.pair2dict exec { setpagedevice } stopped {
483aca
      pop	% the setpagedevice dict
483aca
      /setpagesize $error /errorname get signalerror
483aca
    } {
483aca
      pop pop	% success -- pop the arguments
483aca
    } ifelse
483aca
  } bind def
483aca
-/setduplexmode { /Duplex .dict1 setpagedevice } bind def
483aca
+/setduplexmode { /Duplex //.pair2dict exec setpagedevice } bind def
483aca
 /setmargins
483aca
- { exch 2 array astore /Margins .dict1 setpagedevice
483aca
+ { exch 2 array astore /Margins //.pair2dict exec setpagedevice
483aca
  } bind def
483aca
-/setpagemargin { 0 2 array astore /PageOffset .dict1 setpagedevice } bind def
483aca
+/setpagemargin { 0 2 array astore /PageOffset //.pair2dict exec setpagedevice } bind def
483aca
 /setpageparams
483aca
  { mark /PageSize 6 -2 roll
483aca
    4 index 1 and ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore
483aca
@@ -642,7 +643,7 @@ currentuserparams /WaitTimeout known
483aca
    {
483aca
       /setresolution /typecheck signalerror
483aca
    } if
483aca
-   dup 2 array astore /HWResolution .dict1 { setpagedevice } stopped {
483aca
+   dup 2 array astore /HWResolution //.pair2dict exec { setpagedevice } stopped {
483aca
      pop /setresolution $error /errorname get signalerror
483aca
    } if
483aca
  } bind def
483aca
@@ -1254,3 +1255,10 @@ def
483aca
 %END TN 5044 psuedo-ops
483aca
 
483aca
 end				% level2dict
483aca
+
483aca
+% undefine things defined in this file and not referenced elsewhere
483aca
+[
483aca
+    /.checkprocesscomment
483aca
+    /.pair2dict
483aca
+]
483aca
+{level2dict exch .forceundef} forall
483aca
-- 
483aca
2.20.1
483aca
483aca
483aca
From 932f4106a00e99e4ee32dcc02e57d3636f383ea1 Mon Sep 17 00:00:00 2001
483aca
From: Nancy Durgin <nancy.durgin@artifex.com>
483aca
Date: Wed, 28 Nov 2018 10:09:01 -0800
483aca
Subject: [PATCH 4/6] Undef internal functions from level2dict
483aca
483aca
---
483aca
 Resource/Init/gs_lev2.ps | 6 ++++--
483aca
 1 file changed, 4 insertions(+), 2 deletions(-)
483aca
483aca
diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
483aca
index e6f0645..7638f2a 100644
483aca
--- a/Resource/Init/gs_lev2.ps
483aca
+++ b/Resource/Init/gs_lev2.ps
483aca
@@ -117,7 +117,7 @@ counttomark 2 idiv {
483aca
 } repeat pop
483aca
 /.definepsuserparam {		% <name> <value> .definepsuserparam -
483aca
   psuserparams 3 copy pop
483aca
-  type cvlit /.checkparamtype cvx 2 packedarray cvx put
483aca
+  type cvlit //.checkparamtype /exec load 3 packedarray cvx put
483aca
   userparams 3 1 roll put
483aca
 } .bind def
483aca
 end
483aca
@@ -211,7 +211,7 @@ end
483aca
      } forall
483aca
    } if
483aca
    /setsystemparams //pssystemparams mark exch {
483aca
-     type cvlit /.checkparamtype cvx 2 packedarray cvx
483aca
+     type cvlit //.checkparamtype /exec load 3 packedarray cvx
483aca
    } forall .dicttomark .checksetparams
483aca
         % Set the C-level system params.  If this succeeds, we know that
483aca
         % the password check succeeded.
483aca
@@ -1260,5 +1260,7 @@ end				% level2dict
483aca
 [
483aca
     /.checkprocesscomment
483aca
     /.pair2dict
483aca
+    /.setcolorrendering1
483aca
+    /.checkparamtype
483aca
 ]
483aca
 {level2dict exch .forceundef} forall
483aca
-- 
483aca
2.20.1
483aca
483aca
483aca
From e7ff64cf9b756278f19c87d295ee0fd95c955c05 Mon Sep 17 00:00:00 2001
483aca
From: Nancy Durgin <nancy.durgin@artifex.com>
483aca
Date: Wed, 23 Jan 2019 12:00:30 -0800
483aca
Subject: [PATCH 5/6] Fixed bug caused by the way .checksetparams was undef'd
483aca
483aca
Previously, had undef'd it by making it an operator.
483aca
Now just use an immediate reference and undef it in the gs_lev2.ps file.
483aca
483aca
This fixes bug introduced in commit fe4c47d8e25d6366ecbb5ff487348148b908a89e.
483aca
483aca
Undef'ing .checksetparams by making it an operator doesn't work right because
483aca
errors report .checksetparams as the offending function instead of
483aca
the operator that uses it (setsystemparams in this case).
483aca
483aca
This caused an error in file /tests_private/ps/ps3cet/27-09.PS on page 3,
483aca
where it reports the offending function of some error-handling tests.
483aca
Reporting function should be 'setsystemparams', not '.checksetparams' on
483aca
this page.
483aca
---
483aca
 Resource/Init/gs_init.ps | 1 -
483aca
 Resource/Init/gs_lev2.ps | 7 ++++---
483aca
 2 files changed, 4 insertions(+), 4 deletions(-)
483aca
483aca
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
483aca
index e915f11..a2503f1 100644
483aca
--- a/Resource/Init/gs_init.ps
483aca
+++ b/Resource/Init/gs_init.ps
483aca
@@ -2278,7 +2278,6 @@ SAFER { .setsafeglobal } if
483aca
       /.setuserparams2
483aca
       /.startjob
483aca
       /.checkFilePermitparams
483aca
-      /.checksetparams
483aca
       /.copyparam
483aca
       /.setpagesize
483aca
 
483aca
diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
483aca
index 7638f2a..de1cc94 100644
483aca
--- a/Resource/Init/gs_lev2.ps
483aca
+++ b/Resource/Init/gs_lev2.ps
483aca
@@ -64,7 +64,7 @@ level2dict begin
483aca
       pop
483aca
     } ifelse pop pop
483aca
   } forall pop pop
483aca
-} .bind odef
483aca
+} .bind def
483aca
 
483aca
 % currentuser/systemparams creates and returns a dictionary in the
483aca
 % current VM.  The easiest way to make this work is to copy any composite
483aca
@@ -129,7 +129,7 @@ end
483aca
 /.setuserparams2 {
483aca
         % Check that we will be able to set the PostScript-level
483aca
         % user parameters.
483aca
-  /setuserparams /psuserparams .systemvar .checksetparams
483aca
+  /setuserparams /psuserparams .systemvar //.checksetparams exec
483aca
         % Set the C-level user params.  If this succeeds, we know that
483aca
         % the password check succeeded.
483aca
   dup .setuserparams
483aca
@@ -212,7 +212,7 @@ end
483aca
    } if
483aca
    /setsystemparams //pssystemparams mark exch {
483aca
      type cvlit //.checkparamtype /exec load 3 packedarray cvx
483aca
-   } forall .dicttomark .checksetparams
483aca
+   } forall .dicttomark //.checksetparams exec
483aca
         % Set the C-level system params.  If this succeeds, we know that
483aca
         % the password check succeeded.
483aca
    dup .setsystemparams
483aca
@@ -1262,5 +1262,6 @@ end				% level2dict
483aca
     /.pair2dict
483aca
     /.setcolorrendering1
483aca
     /.checkparamtype
483aca
+    /.checksetparams
483aca
 ]
483aca
 {level2dict exch .forceundef} forall
483aca
-- 
483aca
2.20.1
483aca
483aca
483aca
From 4ec9ca74bed49f2a82acb4bf430eae0d8b3b75c9 Mon Sep 17 00:00:00 2001
483aca
From: Ray Johnston <ray.johnston@artifex.com>
483aca
Date: Thu, 31 Jan 2019 11:31:30 -0800
483aca
Subject: [PATCH 6/6] Hide pdfdict and GS_PDF_ProcSet (internal stuff for the
483aca
 PDF interp).
483aca
483aca
We now keep GS_PDF_ProcSet in pdfdict, and immediately bind pdfdict
483aca
where needed so we can undef it after the last PDF interp file has
483aca
run (pdf_sec.ps).
483aca
---
483aca
 Resource/Init/pdf_base.ps | 11 ++++----
483aca
 Resource/Init/pdf_draw.ps | 59 +++++++++++++++++++--------------------
483aca
 Resource/Init/pdf_font.ps |  9 +++---
483aca
 Resource/Init/pdf_main.ps | 25 +++++++++--------
483aca
 Resource/Init/pdf_ops.ps  | 11 ++++----
483aca
 Resource/Init/pdf_sec.ps  |  4 ++-
483aca
 6 files changed, 60 insertions(+), 59 deletions(-)
483aca
483aca
diff --git a/Resource/Init/pdf_base.ps b/Resource/Init/pdf_base.ps
483aca
index c62ac0e..d3c3a5f 100644
483aca
--- a/Resource/Init/pdf_base.ps
483aca
+++ b/Resource/Init/pdf_base.ps
483aca
@@ -23,7 +23,6 @@
483aca
 
483aca
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
483aca
 .currentglobal //true .setglobal
483aca
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
483aca
 pdfdict begin
483aca
 
483aca
 % Define the name interpretation dictionary for reading values.
483aca
@@ -130,11 +129,11 @@ currentdict /num-chars-dict .undef
483aca
 
483aca
 /.pdfexectoken {		% <count> <opdict> <exectoken> .pdfexectoken ?
483aca
   PDFDEBUG {
483aca
-    pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } executeonly if
483aca
+    //pdfdict /PDFSTEPcount known not { //pdfdict /PDFSTEPcount 1 .forceput } executeonly if
483aca
     PDFSTEP {
483aca
-      pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
483aca
+      //pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
483aca
       PDFSTEPcount 1 gt {
483aca
-        pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
483aca
+        //pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
483aca
       } executeonly
483aca
       {
483aca
         dup ==only
483aca
@@ -142,10 +141,10 @@ currentdict /num-chars-dict .undef
483aca
         ( ? ) print flush 1 //false .outputpage
483aca
         (%stdin) (r) file 255 string readline {
483aca
           token {
483aca
-            exch pop pdfdict /PDFSTEPcount 3 -1 roll .forceput
483aca
+            exch pop //pdfdict /PDFSTEPcount 3 -1 roll .forceput
483aca
           } executeonly
483aca
           {
483aca
-            pdfdict /PDFSTEPcount 1 .forceput
483aca
+            //pdfdict /PDFSTEPcount 1 .forceput
483aca
           } executeonly ifelse % token
483aca
         } {
483aca
           pop /PDFSTEP //false def	 % EOF on stdin
483aca
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
483aca
index d743ae1..1add3f7 100644
483aca
--- a/Resource/Init/pdf_draw.ps
483aca
+++ b/Resource/Init/pdf_draw.ps
483aca
@@ -18,8 +18,7 @@
483aca
 
483aca
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
483aca
 .currentglobal //true .setglobal
483aca
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
483aca
-GS_PDF_ProcSet begin
483aca
+/GS_PDF_ProcSet load begin
483aca
 pdfdict begin
483aca
 
483aca
 % For simplicity, we use a single interpretation dictionary for all
483aca
@@ -113,7 +112,7 @@ pdfdict begin
483aca
 
483aca
 /resolvefunction {	% <fndict> resolvefunction <function>
483aca
   .resolvefn
483aca
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if
483aca
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if
483aca
 } bind executeonly def
483aca
 
483aca
 /resolvefnproc {	% <fndict> resolvefnproc <proc>
483aca
@@ -1073,7 +1072,7 @@ currentdict end readonly def
483aca
 %% finished running the PaintProc.
483aca
 
483aca
 /.actual_pdfpaintproc {         % <patdict> <resdict> .pdfpaintproc -
483aca
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if
483aca
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if
483aca
   PDFfile fileposition 3 1 roll
483aca
   q
483aca
   1 index /PaintType oget 1 eq {
483aca
@@ -1108,21 +1107,21 @@ currentdict end readonly def
483aca
       Q
483aca
     }{
483aca
       (\n   **** Error: File has unbalanced q/Q operators \(too many Q's\)\n               Output may be incorrect.\n)
483aca
-      pdfdict /.Qqwarning_issued .knownget
483aca
+      //pdfdict /.Qqwarning_issued .knownget
483aca
       {
483aca
         {
483aca
           pop
483aca
         }
483aca
         {
483aca
-          currentglobal pdfdict gcheck .setglobal
483aca
-          pdfdict /.Qqwarning_issued //true .forceput
483aca
+          currentglobal //pdfdict gcheck .setglobal
483aca
+          //pdfdict /.Qqwarning_issued //true .forceput
483aca
           .setglobal
483aca
           pdfformaterror
483aca
         } executeonly ifelse
483aca
       }
483aca
       {
483aca
-        currentglobal pdfdict gcheck .setglobal
483aca
-        pdfdict /.Qqwarning_issued //true .forceput
483aca
+        currentglobal //pdfdict gcheck .setglobal
483aca
+        //pdfdict /.Qqwarning_issued //true .forceput
483aca
         .setglobal
483aca
         pdfformaterror
483aca
       } executeonly ifelse
483aca
@@ -1131,21 +1130,21 @@ currentdict end readonly def
483aca
   } loop
483aca
   {
483aca
     (\n   **** Error: File has unbalanced q/Q operators \(too many q's\)\n               Output may be incorrect.\n)
483aca
-    pdfdict /.Qqwarning_issued .knownget
483aca
+    //pdfdict /.Qqwarning_issued .knownget
483aca
     {
483aca
       {
483aca
         pop
483aca
       }
483aca
       {
483aca
-        currentglobal pdfdict gcheck .setglobal
483aca
-        pdfdict /.Qqwarning_issued //true .forceput
483aca
+        currentglobal //pdfdict gcheck .setglobal
483aca
+        //pdfdict /.Qqwarning_issued //true .forceput
483aca
         .setglobal
483aca
         pdfformaterror
483aca
       } executeonly ifelse
483aca
     }
483aca
     {
483aca
-      currentglobal pdfdict gcheck .setglobal
483aca
-      pdfdict /.Qqwarning_issued //true .forceput
483aca
+      currentglobal //pdfdict gcheck .setglobal
483aca
+      //pdfdict /.Qqwarning_issued //true .forceput
483aca
       .setglobal
483aca
       pdfformaterror
483aca
     } executeonly ifelse
483aca
@@ -1156,7 +1155,7 @@ currentdict end readonly def
483aca
   /pdfemptycount exch def
483aca
 
483aca
   Q
483aca
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if
483aca
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if
483aca
   PDFfile exch setfileposition
483aca
 } bind executeonly odef
483aca
 
483aca
@@ -1227,7 +1226,7 @@ currentdict end readonly def
483aca
   ] cvx put
483aca
   dup /BBox 2 copy knownoget { normrect FixPatternBBox put } { pop pop } ifelse
483aca
   dup /.pattern_uses_transparency  1 index patternusestransparency put
483aca
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
483aca
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
483aca
 } bind executeonly def
483aca
 
483aca
 /ignore_color_op  (   **** Error: Ignoring a color operation in a cached context.\n               Output may be incorrect.\n) readonly def
483aca
@@ -2348,16 +2347,16 @@ currentdict /last-ditch-bpc-csp undef
483aca
 } bind executeonly def
483aca
 
483aca
 /IncrementAppearanceNumber {
483aca
-  pdfdict /AppearanceNumber .knownget {
483aca
-    1 add pdfdict /AppearanceNumber 3 -1 roll .forceput
483aca
+  //pdfdict /AppearanceNumber .knownget {
483aca
+    1 add //pdfdict /AppearanceNumber 3 -1 roll .forceput
483aca
   } executeonly
483aca
   {
483aca
-    pdfdict /AppearanceNumber 0 .forceput
483aca
+    //pdfdict /AppearanceNumber 0 .forceput
483aca
   } executeonly ifelse
483aca
 }bind executeonly odef
483aca
 
483aca
 /MakeAppearanceName {
483aca
-  pdfdict /AppearanceNumber get
483aca
+  //pdfdict /AppearanceNumber get
483aca
   10 string cvs
483aca
   dup length 10 add string dup 0 (\{FormName) putinterval
483aca
   dup 3 -1 roll
483aca
@@ -2378,17 +2377,17 @@ currentdict /last-ditch-bpc-csp undef
483aca
   gsave initclip
483aca
   MakeNewAppearanceName
483aca
   .pdfFormName
483aca
-  pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get} {//false}ifelse exch
483aca
-  pdfdict /.PreservePDFForm true .forceput
483aca
+  //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch
483aca
+  //pdfdict /.PreservePDFForm true .forceput
483aca
   DoForm
483aca
-  pdfdict /.PreservePDFForm 3 -1 roll .forceput
483aca
+  //pdfdict /.PreservePDFForm 3 -1 roll .forceput
483aca
   grestore
483aca
 } bind executeonly odef
483aca
 
483aca
 /DoForm {
483aca
   %% save the current value, if its true we will set it to false later, in order
483aca
   %% to prevent us preserving Forms which are used *from* an annotation /Appearance.
483aca
-  pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get} {//false}ifelse exch
483aca
+  //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch
483aca
 
483aca
   %% We may alter the Default* colour spaces, if the Resources
483aca
   %% ColorSpace entry contains one of them. But we don't want that
483aca
@@ -2503,13 +2502,13 @@ currentdict /last-ditch-bpc-csp undef
483aca
   pdfemptycount countdictstack 3 -1 roll
483aca
   /pdfemptycount count 4 sub store
483aca
 
483aca
-  pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get}{//false} ifelse
483aca
+  //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get}{//false} ifelse
483aca
   {
483aca
     %% We must *not* preserve any subsidiary forms (curently at least) as PDF
483aca
     %% form preservation doesn't really work. This is used just for Annotation
483aca
     %% Appearances currently, and if they should happen to use a form, we do not
483aca
     %% want to preserve it.
483aca
-    pdfdict /.PreservePDFForm false .forceput
483aca
+    //pdfdict /.PreservePDFForm false .forceput
483aca
     /q cvx /execform cvx 5 -2 roll
483aca
   } executeonly
483aca
   {
483aca
@@ -2542,7 +2541,7 @@ currentdict /last-ditch-bpc-csp undef
483aca
     saved_DCMYK /DefaultCMYK exch /ColorSpace defineresource pop
483aca
     end
483aca
   } if
483aca
-  pdfdict /.PreservePDFForm 3 -1 roll .forceput
483aca
+  //pdfdict /.PreservePDFForm 3 -1 roll .forceput
483aca
 } bind executeonly odef
483aca
 
483aca
 /_dops_save 1 array def
483aca
@@ -2701,13 +2700,13 @@ drawopdict begin
483aca
     % Start by getting the object number for a Form XObject
483aca
     dup Page /XObject obj_get dup 0 eq not {
483aca
       % Now get the recording dictionary and see if that object number has been seen
483aca
-      pdfdict /Recursive_XObject_D get 1 index known {
483aca
+      //pdfdict /Recursive_XObject_D get 1 index known {
483aca
         (   **** Error: Recursive XObject detected, ignoring ") print 1 index 256 string cvs print (", object number ) print 256 string cvs print (\n) print
483aca
         (               Output may be incorrect.\n) pdfformaterror
483aca
         //false
483aca
       }{
483aca
         % We haven't seen it yet, so record it.
483aca
-        pdfdict /Recursive_XObject_D get 1 index null put
483aca
+        //pdfdict /Recursive_XObject_D get 1 index null put
483aca
         3 1 roll
483aca
         //true
483aca
       }ifelse
483aca
@@ -2745,7 +2744,7 @@ drawopdict begin
483aca
         (               Output may be incorrect.\n) pdfformaterror
483aca
       } ifelse
483aca
       PDFfile exch setfileposition
483aca
-      pdfdict /Recursive_XObject_D get exch undef
483aca
+      //pdfdict /Recursive_XObject_D get exch undef
483aca
     }{
483aca
       % Otherwise ignore it and tidy up the stacks
483aca
       pop pop
483aca
diff --git a/Resource/Init/pdf_font.ps b/Resource/Init/pdf_font.ps
483aca
index 46408f9..275b659 100644
483aca
--- a/Resource/Init/pdf_font.ps
483aca
+++ b/Resource/Init/pdf_font.ps
483aca
@@ -37,8 +37,7 @@
483aca
 
483aca
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
483aca
 .currentglobal //true .setglobal
483aca
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
483aca
-GS_PDF_ProcSet begin
483aca
+/GS_PDF_ProcSet load begin	% from userdict at this point
483aca
 pdfdict begin
483aca
 
483aca
 % We cache the PostScript font in an additional element of the
483aca
@@ -1219,11 +1218,11 @@ currentdict /eexec_pdf_param_dict .undef
483aca
             .pdfruncontext
483aca
             countdictstack BuildCharDictDepth sub
483aca
             {
483aca
-              pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse
483aca
+              //pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse
483aca
               {
483aca
                 (\n   **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n               Output may be incorrect.\n)
483aca
                 pdfformatwarning
483aca
-                pdfdict /.Qqwarning_issued //true .forceput
483aca
+                //pdfdict /.Qqwarning_issued //true .forceput
483aca
               } executeonly if
483aca
               Q
483aca
             } repeat
483aca
@@ -2334,7 +2333,7 @@ currentdict /bndef undef
483aca
   dup //null eq
483aca
   {pop}
483aca
   {
483aca
-    pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if
483aca
+    //pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if
483aca
     exch dup /.OrigUniqueIDXUID .knownget not
483aca
     {
483aca
       dup /XUID .knownget not
483aca
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
483aca
index dd1480b..e44288e 100644
483aca
--- a/Resource/Init/pdf_main.ps
483aca
+++ b/Resource/Init/pdf_main.ps
483aca
@@ -18,8 +18,9 @@
483aca
 
483aca
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
483aca
 .currentglobal //true .setglobal
483aca
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
483aca
 pdfdict begin
483aca
+/GS_PDF_ProcSet dup load def	% keep in pdfdict to hide it
483aca
+userdict /GS_PDF_ProcSet undef
483aca
 
483aca
 % Patch in an obsolete variable used by some third-party software.
483aca
 /#? //false def
483aca
@@ -304,8 +305,8 @@ currentdict /runpdfstring .undef
483aca
    /Page //null def
483aca
    /DSCPageCount 0 def
483aca
    /PDFSave //null def
483aca
-   GS_PDF_ProcSet begin
483aca
-   pdfdict begin
483aca
+   //pdfdict /GS_PDF_ProcSet get begin
483aca
+   //pdfdict begin
483aca
    pdfopen begin
483aca
    /CumulativePageCount currentpagedevice /PageCount get def
483aca
 } bind executeonly def
483aca
@@ -624,7 +625,7 @@ currentdict /runpdfstring .undef
483aca
   %% copied to a temporary file) and store it in pdfdict. We will use this for
483aca
   %% hashing fonts to detect if fonts with the same name are from different files.
483aca
   %%
483aca
-  dup currentglobal exch true setglobal .getfilename exch setglobal /InputPDFFileName exch pdfdict 3 1 roll .forceput
483aca
+  dup currentglobal exch true setglobal .getfilename exch setglobal /InputPDFFileName exch //pdfdict 3 1 roll .forceput
483aca
 
483aca
   //runpdfbegin exec
483aca
   //pdf_collection_files exec
483aca
@@ -1390,7 +1391,7 @@ currentdict /xref-char-dict undef
483aca
 } bind executeonly def
483aca
 
483aca
 /pdfopenfile {		% <file> pdfopenfile <dict>
483aca
-   pdfdict readonly pop		% can't do it any earlier than this
483aca
+   //pdfdict readonly pop		% can't do it any earlier than this
483aca
    32 dict begin
483aca
    /LocalResources 0 dict def
483aca
    /DefaultQstate //null def	% establish binding
483aca
@@ -2684,21 +2685,21 @@ currentdict /PDF2PS_matrix_key undef
483aca
     StreamRunAborted not {
483aca
       (\n   **** Error: File has unbalanced q/Q operators \(too many q's\)\n               Output may be incorrect.\n)
483aca
 
483aca
-      pdfdict /.Qqwarning_issued .knownget
483aca
+      //pdfdict /.Qqwarning_issued .knownget
483aca
       {
483aca
         {
483aca
           pop
483aca
         }
483aca
         {
483aca
-          currentglobal pdfdict gcheck .setglobal
483aca
-          pdfdict /.Qqwarning_issued //true .forceput
483aca
+          currentglobal //pdfdict gcheck .setglobal
483aca
+          //pdfdict /.Qqwarning_issued //true .forceput
483aca
           .setglobal
483aca
           pdfformaterror
483aca
         } executeonly ifelse
483aca
       }
483aca
       {
483aca
-        currentglobal pdfdict gcheck .setglobal
483aca
-        pdfdict /.Qqwarning_issued //true .forceput
483aca
+        currentglobal //pdfdict gcheck .setglobal
483aca
+        //pdfdict /.Qqwarning_issued //true .forceput
483aca
         .setglobal
483aca
         pdfformaterror
483aca
       } executeonly ifelse
483aca
@@ -2710,8 +2711,8 @@ currentdict /PDF2PS_matrix_key undef
483aca
   Repaired		% pass Repaired state around the restore
483aca
   RepairedAnError
483aca
   PDFSave restore
483aca
-  currentglobal pdfdict gcheck .setglobal
483aca
-  pdfdict /.Qqwarning_issued //false .forceput
483aca
+  currentglobal //pdfdict gcheck .setglobal
483aca
+  //pdfdict /.Qqwarning_issued //false .forceput
483aca
   .setglobal
483aca
   /RepairedAnError exch def
483aca
   /Repaired exch def
483aca
diff --git a/Resource/Init/pdf_ops.ps b/Resource/Init/pdf_ops.ps
483aca
index aa09641..c2e7461 100644
483aca
--- a/Resource/Init/pdf_ops.ps
483aca
+++ b/Resource/Init/pdf_ops.ps
483aca
@@ -24,6 +24,7 @@
483aca
 systemdict /pdfmark known not
483aca
  { userdict /pdfmark { cleartomark } bind executeonly put } if
483aca
 
483aca
+systemdict /pdfdict where { pop } { /pdfdict 100 dict put } ifelse
483aca
 userdict /GS_PDF_ProcSet 256 dict dup begin
483aca
 
483aca
 % ---------------- Abbreviations ---------------- %
483aca
@@ -174,21 +175,21 @@ currentdict /gput_always_allow .undef
483aca
   {
483aca
     (\n   **** Error: File has unbalanced q/Q operators \(too many Q's\)\n               Output may be incorrect.\n)
483aca
 
483aca
-    pdfdict /.Qqwarning_issued .knownget
483aca
+    //pdfdict /.Qqwarning_issued .knownget
483aca
     {
483aca
       {
483aca
         pop
483aca
       }
483aca
       {
483aca
-        currentglobal pdfdict gcheck .setglobal
483aca
-        pdfdict /.Qqwarning_issued //true .forceput
483aca
+        currentglobal //pdfdict gcheck .setglobal
483aca
+        //pdfdict /.Qqwarning_issued //true .forceput
483aca
         .setglobal
483aca
         pdfformaterror
483aca
       } executeonly ifelse
483aca
     }
483aca
     {
483aca
-      currentglobal pdfdict gcheck .setglobal
483aca
-      pdfdict /.Qqwarning_issued //true .forceput
483aca
+      currentglobal //pdfdict gcheck .setglobal
483aca
+      //pdfdict /.Qqwarning_issued //true .forceput
483aca
       .setglobal
483aca
       pdfformaterror
483aca
     } executeonly ifelse
483aca
diff --git a/Resource/Init/pdf_sec.ps b/Resource/Init/pdf_sec.ps
483aca
index 143efb7..a8e3d2e 100644
483aca
--- a/Resource/Init/pdf_sec.ps
483aca
+++ b/Resource/Init/pdf_sec.ps
483aca
@@ -39,7 +39,6 @@
483aca
 
483aca
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
483aca
 .currentglobal //true .setglobal
483aca
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
483aca
 pdfdict begin
483aca
 
483aca
 % Older ghostscript versions do not have .pdftoken, so we use 'token' instead.
483aca
@@ -748,4 +747,7 @@ currentdict /PDFScanRules_null undef
483aca
  } bind executeonly def
483aca
 
483aca
 end			% pdfdict
483aca
+
483aca
+systemdict /pdfdict .forceundef		% hide pdfdict
483aca
+
483aca
 .setglobal
483aca
-- 
483aca
2.20.1
483aca