Repository navigation
ROB: Bound object and generation number lengths in _find_pdf_objects - #4334
Open
Rustaman1280 wants to merge 1 commit into
Open
Rustaman1280 wants to merge 1 commit into
Rustaman1280 wants to merge 1 commit into
Conversation
When parsing corrupted PDFs or rebuilding xref tables, _find_pdf_objects parses object numbers and generation numbers preceding 'obj' tokens. Previously, there were no upper bounds on the digit lengths of these slices, allowing oversized digit runs to trigger unhandled ValueError from Python's int_max_str_digits conversion limit. Bound object and generation number string lengths by IndirectObject._MAXIMUM_PART_LENGTH (64 bytes) to safely skip oversized entries and avoid unhandled exceptions. Signed-off-by: Rustaman Delvianova <96533738+Rustaman1280@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4334 +/- ##
=======================================
Coverage 98.65% 98.65%
=======================================
Files 59 59
Lines 11964 11974 +10
Branches 2271 2273 +2
=======================================
+ Hits 11803 11813 +10
Misses 84 84
Partials 77 77 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When parsing corrupted PDFs or rebuilding xref tables,
_find_pdf_objectsparses object numbers and generation numbers precedingobjtokens. Previously, there were no upper bounds on the digit lengths of these slices, allowing oversized digit runs to trigger unhandledValueErrorfrom Python'sint_max_str_digitsconversion limit (Python 3.11+).Bound object and generation number string lengths by
IndirectObject._MAXIMUM_PART_LENGTH(64 bytes) to safely skip oversized entries and avoid unhandled exceptions, following the advisory discussion in GHSA-mw3g-xgcq-g239.Verification
test_find_pdf_objects_integer_conversion_limitintests/test_reader.pyverifying oversized object and generation tokens are safely skipped without leakingValueError.pytest tests/test_reader.py -k "find_pdf_objects"passes cleanly (2/2 passed).ruff checkon changed files reports 0 issues.