[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1554-gf69b63a
[email protected] (Ken Sharp)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via f69b63a3dc3bb7671df956587fe2520f8badab88 (commit)
from fd915a81c605a52f58855bd233c19aaa373b2f69 (commit)
----------------------------------------------------------------------
commit f69b63a3dc3bb7671df956587fe2520f8badab88
Author: Ken Sharp <[email protected]>
Date: Mon Aug 5 17:50:04 2019 +0100
PDF interpreter - cope with strangely constructed Pages trees
Bug #700953 "Error: /execstackoverflow in --.systemvar--"
The pre-interpretation scan of the Pages tree looking for loops in the
tree structure uses recursion; if a Pages tree is badly constructed it
is possible to recurse enough times to cause an overflow of the exec
stack.
We can cope with this by aborting the scan and continuing to interpret
and render the PDF file, because the regular processing of PDF file
doesn't use recursion.
Of course, this does mean that we lose the check for loops in the Pages
tree (at least, loops beyond the point where we overflow the exec stack)
but both conditions are rare, so I think its worth doing.
We do still raise a warning.
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 2b4a0c6..9d70f0d 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -1560,7 +1560,11 @@ currentdict /xref-char-dict undef
{ stop } if
% Check for recursion in the page tree. Bug 689954, MOAB-06-01-2007
+ % Make sure that the operand stack is cleaned up in case there's
+ % an error and we ignore it (bug #700953)
+ mark
verify_page_tree
+ cleartomark
currentdict end
} bind executeonly def
@@ -1996,6 +2000,11 @@ currentdict /xref-char-dict undef
% Check for loops in the 'page tree' but accept an acyclic graph.
% - verify_page_tree -
/verify_page_tree {
+ % Run the verification inside a 'stopped' context. Bug #700953
+ % has a peculiarly constructed page tree, and a huge number of
+ % pages, which recurses to a depth beyond the level we can cope
+ % with on the exec stack. If we ignore that error then we can
+ {
Trailer /Root knownoget {
/Pages knownoget {
10 dict begin
@@ -2028,6 +2037,16 @@ currentdict /xref-char-dict undef
end
} if
} if
+ } stopped
+ {
+ %% Specific check for syntax error, in this case assume we found a loop in the Pages tree.
+ %% (see above). Otherwise, just try to process the file anyway.
+ $error /errorname get /syntaxerror eq {
+ /verify_page_tree cvx /syntaxerror signalerror
+ } {
+ ( **** Error: Something went wrong while checking for recursion in the Page tree. Giving up checking.\n This PDF file may not terminate, if there is a loop in the Pages tree.\n) pdfformaterror
+ } ifelse
+ } if
} bind executeonly def
/pdffindpage? { % <int> pdffindpage? 1 null (page not found)
Summary of changes:
Resource/Init/pdf_main.ps | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)