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

79ccdd
From: Nancy Durgin <nancy.durgin@artifex.com>
79ccdd
Date: Wed, 23 Jan 2019 20:00:30 +0000 (-0800)
79ccdd
Subject: Fixed bug caused by the way .checksetparams was undef'd
79ccdd
79ccdd
Fixed bug caused by the way .checksetparams was undef'd
79ccdd
79ccdd
Previously, had undef'd it by making it an operator.
79ccdd
Now just use an immediate reference and undef it in the gs_lev2.ps file.
79ccdd
79ccdd
This fixes bug introduced in commit fe4c47d8e25d6366ecbb5ff487348148b908a89e.
79ccdd
79ccdd
Undef'ing .checksetparams by making it an operator doesn't work right because
79ccdd
errors report .checksetparams as the offending function instead of
79ccdd
the operator that uses it (setsystemparams in this case).
79ccdd
79ccdd
This caused an error in file /tests_private/ps/ps3cet/27-09.PS on page 3,
79ccdd
where it reports the offending function of some error-handling tests.
79ccdd
Reporting function should be 'setsystemparams', not '.checksetparams' on
79ccdd
this page.
79ccdd
79ccdd
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=e7ff64cf9b756278f19c87d295ee0fd95c955c05
79ccdd
79ccdd
From: Ray Johnston <ray.johnston@artifex.com>
79ccdd
Date: Thu, 31 Jan 2019 19:31:30 +0000 (-0800)
79ccdd
Subject: Hide pdfdict and GS_PDF_ProcSet (internal stuff for the PDF interp).
79ccdd
79ccdd
Hide pdfdict and GS_PDF_ProcSet (internal stuff for the PDF interp).
79ccdd
79ccdd
We now keep GS_PDF_ProcSet in pdfdict, and immediately bind pdfdict
79ccdd
where needed so we can undef it after the last PDF interp file has
79ccdd
run (pdf_sec.ps).
79ccdd
79ccdd
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=4ec9ca74bed49f2a82acb4bf430eae0d8b3b75c9
79ccdd
---
79ccdd
79ccdd
diff -up ghostscript-9.07/Resource/Init/gs_init.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/gs_init.ps
79ccdd
--- ghostscript-9.07/Resource/Init/gs_init.ps.cve-2019-3839-part2	2019-02-28 08:33:56.995374504 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/gs_init.ps	2019-02-28 08:34:35.073879701 +0100
79ccdd
@@ -2222,7 +2222,6 @@ SAFER { .setsafe } if
79ccdd
       /.setuserparams2
79ccdd
       /.startjob
79ccdd
       /.checkFilePermitparams
79ccdd
-      /.checksetparams
79ccdd
       /.copyparam
79ccdd
       /.setpagesize
79ccdd
 
79ccdd
diff -up ghostscript-9.07/Resource/Init/gs_lev2.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/gs_lev2.ps
79ccdd
--- ghostscript-9.07/Resource/Init/gs_lev2.ps.cve-2019-3839-part2	2019-02-28 08:35:01.038542311 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/gs_lev2.ps	2019-02-28 08:38:44.266647686 +0100
79ccdd
@@ -64,7 +64,7 @@ level2dict begin
79ccdd
       pop
79ccdd
     } ifelse pop pop
79ccdd
   } forall pop pop
79ccdd
-} .bind odef
79ccdd
+} .bind def
79ccdd
 
79ccdd
 % currentuser/systemparams creates and returns a dictionary in the
79ccdd
 % current VM.  The easiest way to make this work is to copy any composite
79ccdd
@@ -129,7 +129,7 @@ end
79ccdd
 /.setuserparams2 {
79ccdd
         % Check that we will be able to set the PostScript-level
79ccdd
         % user parameters.
79ccdd
-  /setuserparams /psuserparams .systemvar .checksetparams
79ccdd
+  /setuserparams /psuserparams .systemvar //.checksetparams exec
79ccdd
         % Set the C-level user params.  If this succeeds, we know that
79ccdd
         % the password check succeeded.
79ccdd
   dup .setuserparams
79ccdd
@@ -211,7 +211,7 @@ end
79ccdd
    } if
79ccdd
    /setsystemparams //pssystemparams mark exch {
79ccdd
      type cvlit /.checkparamtype cvx 2 packedarray cvx
79ccdd
-   } forall .dicttomark .checksetparams
79ccdd
+   } forall .dicttomark //.checksetparams exec
79ccdd
         % Set the C-level system params.  If this succeeds, we know that
79ccdd
         % the password check succeeded.
79ccdd
    dup .setsystemparams
79ccdd
@@ -1083,5 +1083,6 @@ end				% level2dict
79ccdd
 [
79ccdd
     /.checkprocesscomment
79ccdd
     /.pair2dict
79ccdd
+    /.checksetparams
79ccdd
 ]
79ccdd
 {level2dict exch .forceundef} forall
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_base.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_base.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_base.ps.cve-2019-3839-part2	2019-02-28 08:51:17.876974739 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_base.ps	2019-02-28 08:53:47.343056275 +0100
79ccdd
@@ -23,7 +23,6 @@
79ccdd
 
79ccdd
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
79ccdd
 .currentglobal //true .setglobal
79ccdd
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
79ccdd
 pdfdict begin
79ccdd
 
79ccdd
 % Define the name interpretation dictionary for reading values.
79ccdd
@@ -125,11 +124,11 @@ currentdict /num-chars-dict .undef
79ccdd
 
79ccdd
 /.pdfexectoken {		% <count> <opdict> <exectoken> .pdfexectoken ?
79ccdd
   PDFDEBUG {
79ccdd
-    pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } executeonly if
79ccdd
+    //pdfdict /PDFSTEPcount known not { //pdfdict /PDFSTEPcount 1 .forceput } executeonly if
79ccdd
     PDFSTEP {
79ccdd
-      pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
79ccdd
+      //pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
79ccdd
       PDFSTEPcount 1 gt {
79ccdd
-        pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
79ccdd
+        //pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
79ccdd
       } executeonly
79ccdd
       {
79ccdd
         dup ==only
79ccdd
@@ -137,10 +136,10 @@ currentdict /num-chars-dict .undef
79ccdd
         ( ? ) print flush 1 //false .outputpage
79ccdd
         (%stdin) (r) file 255 string readline {
79ccdd
           token {
79ccdd
-            exch pop pdfdict /PDFSTEPcount 3 -1 roll .forceput
79ccdd
+            exch pop //pdfdict /PDFSTEPcount 3 -1 roll .forceput
79ccdd
           } executeonly
79ccdd
           {
79ccdd
-            pdfdict /PDFSTEPcount 1 .forceput
79ccdd
+            //pdfdict /PDFSTEPcount 1 .forceput
79ccdd
           } executeonly ifelse % token
79ccdd
         } {
79ccdd
           pop /PDFSTEP //false def	 % EOF on stdin
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_draw.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_draw.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_draw.ps.cve-2019-3839-part2	2019-02-28 08:54:17.090674446 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_draw.ps	2019-02-28 09:06:50.804906849 +0100
79ccdd
@@ -18,8 +18,7 @@
79ccdd
 
79ccdd
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
79ccdd
 .currentglobal //true .setglobal
79ccdd
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
79ccdd
-GS_PDF_ProcSet begin
79ccdd
+/GS_PDF_ProcSet load begin
79ccdd
 pdfdict begin
79ccdd
 
79ccdd
 % For simplicity, we use a single interpretation dictionary for all
79ccdd
@@ -141,7 +140,7 @@ pdfdict begin
79ccdd
 
79ccdd
 /resolvefunction {	% <fndict> resolvefunction <function>
79ccdd
   .resolvefn
79ccdd
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if
79ccdd
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if
79ccdd
 } bdef
79ccdd
 
79ccdd
 /resolvefnproc {	% <fndict> resolvefnproc <proc>
79ccdd
@@ -907,7 +906,7 @@ currentdict end readonly def
79ccdd
 } bdef
79ccdd
 
79ccdd
 /.pdfpaintproc {         % <patdict> <resdict> .pdfpaintproc -
79ccdd
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if
79ccdd
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if
79ccdd
   PDFfile fileposition 3 1 roll
79ccdd
   q
79ccdd
   1 index /PaintType oget 1 eq {
79ccdd
@@ -946,7 +945,7 @@ currentdict end readonly def
79ccdd
   /pdfemptycount exch def
79ccdd
 
79ccdd
   Q
79ccdd
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if
79ccdd
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if
79ccdd
   PDFfile exch setfileposition
79ccdd
 }bind executeonly odef
79ccdd
 
79ccdd
@@ -986,7 +985,7 @@ currentdict end readonly def
79ccdd
   ] cvx put
79ccdd
   dup /BBox 2 copy knownoget { normrect put } { pop pop } ifelse
79ccdd
   dup /.pattern_uses_transparency  1 index patternusestransparency put
79ccdd
-  PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
79ccdd
+  PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
79ccdd
 } bdef
79ccdd
 
79ccdd
 /ignore_color_op  (   **** Warning: Ignoring a color operation in a cached context.\n) readonly def
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_font.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_font.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_font.ps.cve-2019-3839-part2	2019-02-28 09:55:34.701833501 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_font.ps	2019-02-28 09:56:27.116147620 +0100
79ccdd
@@ -37,8 +37,7 @@
79ccdd
 
79ccdd
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
79ccdd
 .currentglobal //true .setglobal
79ccdd
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
79ccdd
-GS_PDF_ProcSet begin
79ccdd
+/GS_PDF_ProcSet load begin     % from userdict at this point
79ccdd
 pdfdict begin
79ccdd
 
79ccdd
 % We cache the PostScript font in an additional element of the
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_main.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_main.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_main.ps.cve-2019-3839-part2	2019-02-28 10:02:48.872152118 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_main.ps	2019-02-28 10:12:44.687353440 +0100
79ccdd
@@ -18,8 +18,9 @@
79ccdd
 
79ccdd
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
79ccdd
 .currentglobal //true .setglobal
79ccdd
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
79ccdd
 pdfdict begin
79ccdd
+/GS_PDF_ProcSet dup load def   % keep in pdfdict to hide it
79ccdd
+userdict /GS_PDF_ProcSet undef
79ccdd
 
79ccdd
 % Patch in an obsolete variable used by some third-party software.
79ccdd
 /#? //false def
79ccdd
@@ -177,8 +178,8 @@ currentdict /runpdfstring .undef
79ccdd
    /Page //null def
79ccdd
    /DSCPageCount 0 def
79ccdd
    /PDFSave //null def
79ccdd
-   GS_PDF_ProcSet begin
79ccdd
-   pdfdict begin
79ccdd
+   //pdfdict /GS_PDF_ProcSet get begin
79ccdd
+   //pdfdict begin
79ccdd
    pdfopen begin
79ccdd
 } bind def
79ccdd
 
79ccdd
@@ -888,7 +889,7 @@ currentdict /xref-char-dict undef
79ccdd
 } bind def
79ccdd
 
79ccdd
 /pdfopenfile {		% <file> pdfopenfile <dict>
79ccdd
-   pdfdict readonly pop		% can't do it any earlier than this
79ccdd
+   //pdfdict readonly pop              % can't do it any earlier than this
79ccdd
    32 dict begin
79ccdd
    /LocalResources 0 dict def
79ccdd
    /DefaultQstate //null def	% establish binding
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_ops.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_ops.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_ops.ps.cve-2019-3839-part2	2019-02-28 10:16:15.196597921 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_ops.ps	2019-02-28 10:17:01.082997269 +0100
79ccdd
@@ -24,6 +24,7 @@
79ccdd
 systemdict /pdfmark known not
79ccdd
  { userdict /pdfmark { cleartomark } bind put } if
79ccdd
 
79ccdd
+systemdict /pdfdict where { pop } { /pdfdict 100 dict put } ifelse
79ccdd
 userdict /GS_PDF_ProcSet 127 dict dup begin
79ccdd
 
79ccdd
 % ---------------- Abbreviations ---------------- %
79ccdd
diff -up ghostscript-9.07/Resource/Init/pdf_sec.ps.cve-2019-3839-part2 ghostscript-9.07/Resource/Init/pdf_sec.ps
79ccdd
--- ghostscript-9.07/Resource/Init/pdf_sec.ps.cve-2019-3839-part2	2019-02-28 10:21:16.760650506 +0100
79ccdd
+++ ghostscript-9.07/Resource/Init/pdf_sec.ps	2019-02-28 10:22:46.213473549 +0100
79ccdd
@@ -39,7 +39,6 @@
79ccdd
 
79ccdd
 /.setlanguagelevel where { pop 2 .setlanguagelevel } if
79ccdd
 .currentglobal //true .setglobal
79ccdd
-/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
79ccdd
 pdfdict begin
79ccdd
 
79ccdd
 % Older ghostscript versions do not have .pdftoken, so we use 'token' instead.
79ccdd
@@ -719,4 +718,7 @@ currentdict /PDFScanRules_null undef
79ccdd
  } bind def
79ccdd
 
79ccdd
 end			% pdfdict
79ccdd
+
79ccdd
+systemdict /pdfdict .forceundef                % hide pdfdict
79ccdd
+
79ccdd
 .setglobal