Skip to content

ROB: Bound object and generation number lengths in _find_pdf_objects - #4334

Open
Rustaman1280 wants to merge 1 commit into
py-pdf:mainfrom
Rustaman1280:fix/bound-find-objects-length
Open

Rustaman1280 wants to merge 1 commit into
py-pdf:mainfrom
Rustaman1280:fix/bound-find-objects-length

Conversation

@Rustaman1280

Copy link
Copy Markdown

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 (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

  • Added test_find_pdf_objects_integer_conversion_limit in tests/test_reader.py verifying oversized object and generation tokens are safely skipped without leaking ValueError.
  • pytest tests/test_reader.py -k "find_pdf_objects" passes cleanly (2/2 passed).
  • ruff check on changed files reports 0 issues.

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>
Copilot AI balanced review requested due to automatic review settings November 1, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (140204c) to head (a49ff30).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants