summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2018-08-28 16:27:53 +0100
committerKen Sharp <ken.sharp@artifex.com>2018-08-28 16:28:13 +0100
commit520bb0ea7519aa3e79db78aaf0589dae02103764 (patch)
tree415d859d2557e447824142d73a8d15c1b7c98728
parent21ae2f8d9953ffe8d6c8f1b2bf72a14b54d50e74 (diff)
downloadghostpdl-520bb0ea7519aa3e79db78aaf0589dae02103764.tar.gz
Bug #699654 (again) and Bug #699677 Improve operator removal for SAFER
Take inspiration from the code to remove unused/dangerous operators and, when SAFER is true, remove a bunch more non-standard operators or routines. In particular remove the .bindnow operator, which should have been removed previously for Bug #699677 and remove the .pushpdf14devicefilter for Bug #699654. Only the PDF interpreter needs to use that, and the device in question only expects to be used carefully and in the correct sequence. Make sure nobody can meddle with it. In addition I removed a number of other operators which are not needed in normal operation. Some of them, however, are useful so these (with the exception of .bindnow which is always removed) are only undefined if SAFER is true. This allows our QA procedure to continue to use them, which is particularly important in the case of .makeoperator and .setCPSImode. At a later date we may choose to move some of these into the regular undefinition code, ie not dependent on SAFER.
-rw-r--r--Resource/Init/gs_init.ps36
1 files changed, 28 insertions, 8 deletions
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
index aa4aaa630..36b7d8a54 100644
--- a/Resource/Init/gs_init.ps
+++ b/Resource/Init/gs_init.ps
@@ -2135,6 +2135,26 @@ readonly def
% If we are running in SAFER mode, lock things down
SAFER { .setsafeglobal } if
+/SAFERUndefinePostScriptOperators {
+[
+% Used by our own test suite files
+/.pushpdf14devicefilter % transparency-example.ps
+/.poppdf14devicefilter % transparency-example.ps
+/.setopacityalpha % transparency-example.ps
+/.setshapealpha % transparency-example.ps
+/.endtransparencygroup % transparency-example.ps
+/.setdotlength % Bug687720.ps
+/.sort /.setdebug /.mementolistnewblocks /getenv
+
+/.makeoperator /.setCPSImode % gs_cet.ps, this won't work on cluster with -dSAFER
+
+/unread
+]
+{systemdict exch .forceundef} forall
+
+//systemdict /SAFERUndefinePostScriptOperators .forceundef
+}bind def
+
/UndefinePostScriptOperators {
%% This list is of Display PostScript operators. We believe that Display PostScript
@@ -2214,7 +2234,7 @@ SAFER { .setsafeglobal } if
%/.buildfotn32 /.buildfont42 /.type9mapcid /.type11mapcid /.swapcolors
%/currentdevice /.quit /.setuseciecolor /.needinput /.setoverprintmode /.special_op /.dicttomark /.knownget
%/.FAPIavailable /.FAPIpassfont /.FAPIrebuildfont /.FAPIBuildGlyph /.FAPIBuildChar /.FAPIBuildGlyph9
-%/.tempfile /.numicc_components /.set_outputintent /.max /.min /.shfill /.vmreclaim /.getpath /.setglobal
+%/.tempfile /.numicc_components /.set_outputintent /.max /.min /.vmreclaim /.getpath /.setglobal
%/.setdebug /.mementolistnewblocks /getenv
]
{systemdict exch .forceundef} forall
@@ -2244,13 +2264,6 @@ SAFER { .setsafeglobal } if
/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize
/.setdistillerparams
-% Used by our own test suite files
-%/.pushpdf14devicefilter % transparency-example.ps
-%/.poppdf14devicefilter % transparency-example.ps
-%/.setopacityalpha % transparency-example.ps
-%/.setshapealpha % transparency-example.ps
-%/.endtransparencygroup % transparency-example.ps
-
% undefining these causes errors/incorrect output
%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint
%/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
@@ -2272,6 +2285,9 @@ SAFER { .setsafeglobal } if
//systemdict /.delaybind {} .forceput % reclaim the space
//systemdict /.bindnow .forceundef % ditto
put
+ SAFER {
+ //systemdict /SAFERUndefinePostScriptOperators get exec
+ } if
//systemdict /UndefinePostScriptOperators get exec
//systemdict /UndefinePDFOperators get exec
//systemdict /.forcecopynew .forceundef % remove temptation
@@ -2385,6 +2401,9 @@ currentdict /.renderingintentdict .undef
%% If we are using DELAYBIND we have to defer the undefinition
%% until .bindnow.
DELAYBIND not {
+ SAFER {
+ //systemdict /SAFERUndefinePostScriptOperators get exec
+ } if
//systemdict /UndefinePostScriptOperators get exec
//systemdict /UndefinePDFOperators .forceundef
} if
@@ -2395,6 +2414,7 @@ end
{ pop NOGC not { 2 .vmreclaim 0 vmreclaim } if
} if
DELAYBIND not {
+ systemdict /.bindnow .undef % We only need this for DELAYBIND
systemdict /.forcecopynew .undef % remove temptation
systemdict /.forcedef .undef % ditto
systemdict /.forceput .undef % ditto