From a11549a566ceed28bc9f6ba100b0d3f6ae59a1f4 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 21 Feb 2015 18:22:32 -0500 Subject: Detect loops in /Pages structure Pushing inherited objects to pages and getting all pages were both prone to stack overflow infinite loops if there were loops in the Pages dictionary. There is a general weakness in the code in that any part of the code that traverses the Pages structure would be prone to this and would have to implement its own loop detection. A more robust fix may provide some general method for handling the Pages structure, but it's probably not worth doing. Note: addition of *Internal2 private functions was done rather than changing signatures of existing methods to avoid breaking compatibility. --- include/qpdf/QPDF.hh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index dfce40c1..71ff7e27 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -668,6 +668,9 @@ class QPDF void getAllPagesInternal(QPDFObjectHandle cur_pages, std::vector& result); + void getAllPagesInternal2(QPDFObjectHandle cur_pages, + std::vector& result, + std::set& visited); void insertPage(QPDFObjectHandle newpage, int pos); int findPage(QPDFObjGen const& og); int findPage(QPDFObjectHandle& page); @@ -1023,6 +1026,12 @@ class QPDF std::map >&, std::vector& all_pages, bool allow_changes, bool warn_skipped_keys); + void pushInheritedAttributesToPageInternal2( + QPDFObjectHandle, + std::map >&, + std::vector& all_pages, + bool allow_changes, bool warn_skipped_keys, + std::set& visited); void updateObjectMaps(ObjUser const& ou, QPDFObjectHandle oh); void updateObjectMapsInternal(ObjUser const& ou, QPDFObjectHandle oh, std::set& visited, bool top); -- cgit v1.2.3-70-g09d2