Subject: Re: [gs-devel] Recent ghostscript broke preview-latex again

From: Chris Liddell <[email-masked]>
Date: Mon, 14 Oct 2019 08:27:35 +0100

This is almost certainly down to the fact that, for improved security,
the file access controls (PermitFileReading etc) are no longer stored as
Postscript objects - that is, they are not user parameters any more.

Before you call .locksafe, adding something like:

systemdict /.addcontrolpath known
{
  /PermitFileReading (bbb.pdf) .addcontrolpath
  /PermitFileReading (bbb.prv/tmp0UabeI/preview.dsc) .addcontrolpath
} if

That should work, and retain functionality with 9.27 and earlier releases.

Note that any attempt to ".addcontrolpath" *after* calling .locksafe
will result in a fatal error and immediate exit from the interpreter.

Regards,

Chris

On 13/10/2019 19:15, Ikumi Keita wrote:
> Dear Ghostscript developers,
> 
> Thank you for your continuing work on developing gs.  Unfortunately, I
> have to inform you that recent gs source became not compatible with
> preview-latex again:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37719
> 
> I tried both gs 9.28 RC4 and fresh checkout of git repository of
> ghostpdl.  I installed each of them with
> env MAKE=gmake ./configure --prefix=$HOME/gs
> gmake
> gmake install
> and set up the relavant path for this temporal installation, on FreeBSD
> 12.0 living in vmware on windows 10 home edition.  Then the invocation
> of gs failed with a message quoted at the last of this message.
> 
> At the time of previous correspondence between us in this July,
> preview-latex did work with gs 9.27 with patches suggested in
> https://ghostscript.com/pipermail/gs-devel/2019-July/010161.html
> applied, but it no longer does.  (By the way, the LaTeX developer
> released new LaTeX this October, so the internal of the PDF file
> produced by pdflatex might have some subtle difference from July.  I
> attach the current PDF for reference.)
> 
> Could you please take a look and try to find a way to recover
> preview-latex functionality?
> 
> Best regards,
> Ikumi Keita
> 
> /home/keita/gs/bin/gs -dOutputFile\=\(bbb.prv/tmp0UabeI/pr1-1.png\) -q -dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r108.606x108.587 -dDELAYBIND
> GS>{<</PermitFileReading[(bbb.pdf)(bbb.prv/tmp0UabeI/preview.dsc)]>> setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne or{.preview-BP gsave 1 1 0.878431 setrgbcolor clippath fill grestore }{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-do{/.preview-ST[count 4 roll save]def dup length 0 eq{pop}{setpagedevice}{ifelse exec}stopped{handleerror quit}if .preview-ST aload pop restore}bind def  (bbb.prv/tmp0UabeI/preview.dsc)(r)file /.preview-ST 1 index def dup 0 setfileposition 407()/SubFileDecode filter cvx exec .preview-ST dup dup 407 setfileposition 51()/SubFileDecode filter cvx<<>>preview-do
> Error: /invalidfileaccess in --file--
> Operand stack:
>    (bbb.prv/tmp0UabeI/preview.dsc)   (r)
> Execution stack:
>    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
> Dictionary stack:
>    --dict:1175/1684(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
> Current allocation mode is local
> Last OS error: Permission denied
> Current file position is 606
> GS<2>
>