diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2017-05-11 13:09:29 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2017-05-12 13:51:03 +0100 |
commit | 1497d65039885a52b598b137dd8622bd4672f9be (patch) | |
tree | b4dbee00160d037ae26b9dd8969a1f07d4aae1b4 | |
parent | 0072619f46f89e0c7406160d4829bccda314b37d (diff) |
Remove as many non-standard operators as possible
Remove all the Display PostScript operators and all the NeXT extensions
Remove all the operators which do not appear to be used in our code
Remove all the operators which are only used in bound procedures defined
at startup and which can therefore subsequently be removed.
The operators to be undefined are stored in arrays in PostScript and
the C support code is untouched. This means that it is relatively
simple for an end user to restore an operator if required.
Operators which are used in our test suite files are listed in the
arrays but commented out.
Operators which are used (by our own code) in a way which requires them
to be present are also listed in the arrays, but commented out.
-rw-r--r-- | Resource/Init/gs_init.ps | 78 | ||||
-rw-r--r-- | Resource/Init/pdf_main.ps | 27 |
2 files changed, 105 insertions, 0 deletions
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps index 3d7a1c712..589e05063 100644 --- a/Resource/Init/gs_init.ps +++ b/Resource/Init/gs_init.ps | |||
@@ -2229,6 +2229,80 @@ currentdict /.patterntypes .undef | |||
2229 | currentdict /.shadingtypes .undef | 2229 | currentdict /.shadingtypes .undef |
2230 | currentdict /.wheredict .undef | 2230 | currentdict /.wheredict .undef |
2231 | currentdict /.renderingintentdict .undef | 2231 | currentdict /.renderingintentdict .undef |
2232 | |||
2233 | %% This list is of Display PostScript operators. We believe that Display PostScript | ||
2234 | %% was never fully implemented and the only known user, GNUStep, is no longer | ||
2235 | %% using it. So lets remove it. | ||
2236 | [ | ||
2237 | /condition /currentcontext /detach /.fork /join /.localfork /lock /monitor /notify | ||
2238 | /wait /yield /.currentscreenphase /.setscreenphase /.image2 /eoviewclip /initviewclip | ||
2239 | /viewclip /viewclippath /defineusername | ||
2240 | %% NeXT DPS extensions | ||
2241 | /currentalpha /setalpha /.alphaimage /composite /compositerect /dissolve /sizeimagebox /.sizeimageparams | ||
2242 | ] | ||
2243 | {currentdict exch .undef} forall | ||
2244 | |||
2245 | %% This list is of operators which no longer appear to be used, and which we do not believe | ||
2246 | %% to have any real use. For now we will undefine the operstors so they cannot easily be used | ||
2247 | %% but can be easily restored (just delete the name from the list in the array). In future | ||
2248 | %% we may remove the operator and the code implementation entirely. | ||
2249 | [ | ||
2250 | /.bitadd /.charboxpath /.currentblackptcomp /.setblackptcomp /.cond /.countexecstack /.execstack /.runandhide /.popdevicefilter | ||
2251 | /.execfile /.filenamesplit /.file_name_parent | ||
2252 | /.setdefaultmatrix /.isprocfilter /.unread /.psstringencode | ||
2253 | /.buildsampledfunction /.isencapfunction /.currentaccuratecurves /.currentcurvejoin /.currentdashadapt /.currentdotlength | ||
2254 | /.currentlimitclamp /.dotorientation /.setaccuratecurves /.setcurvejoin /.setdashadapt /.setdotorientation | ||
2255 | /.setlimitclamp /.currentscreenlevels /.dashpath /.pathbbox /.identeq /.identne /.tokenexec /.forgetsave /.pantonecallback | ||
2256 | |||
2257 | % Used by our own test suite files | ||
2258 | %/.setdotlength % Bug687720.ps | ||
2259 | ] | ||
2260 | {currentdict exch .undef} forall | ||
2261 | |||
2262 | %% This list of operators are used internally by various parts of the Ghostscript startup code. | ||
2263 | %% Since each operator is a potential security vulnerability, and any operator listed here | ||
2264 | %% is not required once the initislisation is complete and functions are bound, we undefine | ||
2265 | %% the ones that aren't needed at runtime. | ||
2266 | [ | ||
2267 | /.callinstall /.callbeginpage /.callendpage | ||
2268 | /.currentstackprotect /.setstackprotect /.errorexec /.finderrorobject /.installsystemnames /.bosobject /.fontbbox | ||
2269 | /.type1execchar /.type2execchar /.type42execchar /.setweightvector /.getuseciecolor /processcolors /.includecolorspace | ||
2270 | /.execn /.instopped /.stop /.stopped /.setcolorrendering /.setdevicecolorrendering /.buildcolorrendering1 /.builddevicecolorrendering1 | ||
2271 | /.TransformPQR_scale_WB0 /.TransformPQR_scale_WB1 /.TransformPQR_scale_WB2 /.currentoverprintmode /.copydevice2 | ||
2272 | /.devicename /.doneshowpage /flushpage /.getbitsrect /.getdevice /.getdefaultdevice /.getdeviceparams /.gethardwareparams | ||
2273 | /makewordimagedevice /.outputpage /.putdeviceparams /.setdevice /.currentshowpagecount | ||
2274 | /.setpagedevice /.currentpagedevice /.knownundef /.setmaxlength /.rectappend /.initialize_dsc_parser /.parse_dsc_comments | ||
2275 | /.fillCIDMap /.fillIdentityCIDMap /.buildcmap /.filenamelistseparator /.libfile /.getfilename | ||
2276 | /.file_name_combine /.file_name_is_absolute /.file_name_separator /.file_name_directory_separator /.file_name_current /.filename | ||
2277 | /.peekstring /.writecvp /.subfiledecode /.setupUnicodeDecoder /.jbig2makeglobalctx /.registerfont /.parsecff | ||
2278 | /.getshowoperator /.getnativefonts /.beginform /.endform /.get_form_id /.repeatform /.reusablestream /.rsdparams | ||
2279 | /.buildfunction /.currentfilladjust2 /.setfilladjust2 /.sethpglpathmode /.currenthpglpathmode | ||
2280 | /.currenthalftone /.sethalftone5 /.image1 /.imagemask1 /.image3 /.image4 | ||
2281 | /.getiodevice /.getdevparms /.putdevparams /.bbox_transform /.matchmedia /.matchpagesize /.defaultpapersize | ||
2282 | /.oserrno /.setoserrno /.oserrorstring /.getCPSImode | ||
2283 | /.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage /.buildpattern1 /.saslprep | ||
2284 | /.buildshading1 /.buildshadin2 /.buildshading3 /.buildshading4 /.buildshading5 /.buildshading6 /.buildshading7 /.buildshadingpattern | ||
2285 | /.argindex /.bytestring /.namestring /.stringbreak /.stringmatch /.globalvmarray /.globalvmdict /.globalvmpackedarray /.globalvmstring | ||
2286 | /.localvmarray /.localvmdict /.localvmpackedarray /.localvmstring /.systemvmarray /.systemvmdict /.systemvmpackedarray /.systemvmstring /.systemvmfile /.systemvmlibfile | ||
2287 | /.systemvmSFD /.settrapparams /.currentsystemparams /.currentuserparams /.getsystemparam /.getuserparam /.setsystemparams /.setuserparams | ||
2288 | /.checkpassword /.locale_to_utf8 /.currentglobal /.gcheck /.imagepath | ||
2289 | |||
2290 | % Used by our own test suite files | ||
2291 | %/.fileposition %image-qa.ps | ||
2292 | %/.makeoperator /.setCPSImode % gs_cet.ps | ||
2293 | |||
2294 | % Either our code uses these in ways which mean they can't be undefined, or they are used directly by | ||
2295 | % test files/utilities, or engineers expressed a desire to keep them visible. | ||
2296 | % | ||
2297 | %/currentdevice /.sort /.buildfont0 /.buildfont1 /.buildfont2 /.buildfont3 /.buildfont4 /.buildfont9 /.buildfont10 /.buildfont11 | ||
2298 | %/.buildfotn32 /.buildfont42 /.type9mapcid /.type11mapcid /.swapcolors | ||
2299 | %/currentdevice /.quit /.setuseciecolor /.needinput /.setoverprintmode /.special_op /.dicttomark /.knownget | ||
2300 | %/.FAPIavailable /.FAPIpassfont /.FAPIrebuildfont /.FAPIBuildGlyph /.FAPIBuildChar /.FAPIBuildGlyph9 | ||
2301 | %/.tempfile /.numicc_components /.set_outputintent /.max /.min /.shfill /.vmreclaim /.getpath /.setglobal | ||
2302 | %/.setdebug /.mementolistnewblocks /getenv | ||
2303 | ] | ||
2304 | {currentdict exch .undef} forall | ||
2305 | |||
2232 | end | 2306 | end |
2233 | 2307 | ||
2234 | % Clean up VM, and enable GC. Use .vmreclaim to force the GC. | 2308 | % Clean up VM, and enable GC. Use .vmreclaim to force the GC. |
@@ -2246,6 +2320,10 @@ systemdict /superexec .knownget { | |||
2246 | 1183615869 internaldict /superexec 3 -1 roll put | 2320 | 1183615869 internaldict /superexec 3 -1 roll put |
2247 | systemdict /superexec .undef | 2321 | systemdict /superexec .undef |
2248 | } if | 2322 | } if |
2323 | |||
2324 | %% Can't remove this one until the last minute :-) | ||
2325 | systemdict /.undef .undef | ||
2326 | |||
2249 | WRITESYSTEMDICT not { systemdict readonly pop } if | 2327 | WRITESYSTEMDICT not { systemdict readonly pop } if |
2250 | (END GC) VMDEBUG | 2328 | (END GC) VMDEBUG |
2251 | 2329 | ||
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index 59d88ef29..ec7cd31e6 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps | |||
@@ -3122,3 +3122,30 @@ currentdict /PDF2PS_matrix_key undef | |||
3122 | 3122 | ||
3123 | end % pdfdict | 3123 | end % pdfdict |
3124 | .setglobal | 3124 | .setglobal |
3125 | |||
3126 | %% This list of operators are used internally by various parts of the Ghostscript PDF interpreter. | ||
3127 | %% Since each operator is a potential security vulnerability, and any operator listed here | ||
3128 | %% is not required once the initislisation is complete and functions are bound, we undefine | ||
3129 | %% the ones that aren't needed at runtime. | ||
3130 | [ | ||
3131 | /.pdfawidthshow /.pdfwidthshow | ||
3132 | /.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent | ||
3133 | /.currentstrokeoverprint /.setstrokeoverprint /.currentfilloverprint /.setfilloverprint | ||
3134 | /.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading | ||
3135 | /.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling | ||
3136 | /.setTextLineMatrix /.currentTextLineMatrix /.currentTextMatrix /.setTextMatrix /.currentblendmode | ||
3137 | /.currentopacityalpha /.currentshapealpha /.currenttextknockout | ||
3138 | /.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup | ||
3139 | /.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x | ||
3140 | /.abortpdf14devicefilter /.pdfinkpath /.pdfFormName | ||
3141 | |||
3142 | % Used by our own test suite files | ||
3143 | %/.pushpdf14devicefilter % transparency-example.ps | ||
3144 | %/.poppdf14devicefilter % transparency-example.ps | ||
3145 | %/.setopacityalpha % transparency-example.ps | ||
3146 | %/.setshapealpha % transparency-example.ps | ||
3147 | %/.endtransparencygroup % transparency-example.ps | ||
3148 | |||
3149 | %/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password | ||
3150 | ] | ||
3151 | {systemdict exch .undef} forall | ||