Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely exit infinite loops on AProfile.outlinesOK / checkItemOutline #704

Merged

Conversation

karenhanson
Copy link
Contributor

@karenhanson karenhanson commented Jan 26, 2022

Other parts of the code have recursion detection, but here incorrect or mishandled escape characters can cause infinite loops. This change safely exits the loop and logs a message, similar to how things are handled in PDFModule.buildOutlineItemProperty - and it uses the same INFO message.

Proposing this change in relation to #652, #645, #646, #277, #473, #306. Regardless of how these backslash issues are fixed, there is a failure to exit the loop safely rather than crash JHOVE. I think we might need this or something similar.

I'm not sure why there is specific handling of the case when next is same as child here:

if (next.getObjNumber() != child.getObjNumber()) {

So I left that in there. It is possible this is a prior attempt to handle infinite loops... if it is we could condense my suggestion to throw the recursion info exception when any node is revisited in outlinesOK or checkItemOutline.

@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #704 (fcff0e2) into integration (53efb61) will not change coverage.
The diff coverage is n/a.

@@              Coverage Diff               @@
##             integration     #704   +/-   ##
==============================================
  Coverage          45.75%   45.75%           
  Complexity          1051     1051           
==============================================
  Files                 57       57           
  Lines               9145     9145           
  Branches            1684     1684           
==============================================
  Hits                4184     4184           
  Misses              4405     4405           
  Partials             556      556           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 810728c...fcff0e2. Read the comment docs.

@karenhanson karenhanson force-pushed the checkItemOutline-loop branch from b5627d3 to 95e8cbb Compare February 3, 2022 22:04
@karenhanson karenhanson changed the title Safely exit infinite loops on AProfile.checkItemOutline Safely exit infinite loops on AProfile.outlinesOK / checkItemOutline Feb 3, 2022
Other parts of the code have recursion detection, but here incorrect or mishandled escape characters can cause infinite loops. This safely exits the loop on either AProfile.outlinesOK() or AProfile.checkItemOutline() and logs a message, similar to how things are handled in PDFModule.buildOutlineItemProperty - uses the same message.
@carlwilson carlwilson self-requested a review April 7, 2022 22:18
@carlwilson carlwilson added bug A product defect that needs fixing P2 Medium priority issues to be scheduled in a future release RC1.26 labels Apr 7, 2022
@carlwilson carlwilson added this to the JHOVE 1.26 milestone Apr 7, 2022
@carlwilson carlwilson merged commit bbd5900 into openpreserve:integration Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A product defect that needs fixing P2 Medium priority issues to be scheduled in a future release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants