Skip to content

ROB: Improve handling of LZW decoder table overflow#3159

Merged
stefan6419846 merged 2 commits intopy-pdf:mainfrom
stefan6419846:issue3032
Feb 27, 2025
Merged

ROB: Improve handling of LZW decoder table overflow#3159
stefan6419846 merged 2 commits intopy-pdf:mainfrom
stefan6419846:issue3032

Conversation

@stefan6419846
Copy link
Copy Markdown
Collaborator

Closes #3032.

@stefan6419846
Copy link
Copy Markdown
Collaborator Author

Generate the test file: Comment

result_codes.append(self.CLEAR_TABLE_MARKER)
and run the following code:

import string

from pypdf._codecs._codecs import LzwCodec

data = string.printable + string.printable[::-1]
for _ in range(8):
    data += data
data = data[:-12410]

codec = LzwCodec()
encoded = codec.encode(data.encode())

with open('resources/lzw_decoder_table_overflow.bin', mode='wb') as fd:
    fd.write(encoded)

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.53%. Comparing base (6003a1e) to head (7ab6192).
Report is 96 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3159   +/-   ##
=======================================
  Coverage   96.53%   96.53%           
=======================================
  Files          53       53           
  Lines        8909     8914    +5     
  Branches     1633     1634    +1     
=======================================
+ Hits         8600     8605    +5     
  Misses        185      185           
  Partials      124      124           

☔ View full report in Codecov by Sentry.
📢 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.

@stefan6419846 stefan6419846 merged commit f15ddca into py-pdf:main Feb 27, 2025
16 checks passed
@stefan6419846 stefan6419846 deleted the issue3032 branch February 27, 2025 08:24
stefan6419846 added a commit that referenced this pull request Mar 2, 2025
## What's new

### Bug Fixes (BUG)
- Use the correct name StandardEncoding for the predefined cmap (#3156) by @stefan6419846
- Handle inline images containing `EI ` sequences (#3152) by @stefan6419846
- Fix check box value which should be name object (#3124) by @stefan6419846
- Fix stream position on inline image fallback extraction (#3120) by @stefan6419846
- Fix object count for incremental writer (#3117) by @m32

### Robustness (ROB)
- Avoid index errors on empty lines in xref table (#3162) by @stefan6419846
- Improve handling of LZW decoder table overflow (#3159) by @stefan6419846
- Ignore non-numbers for width when building font width map (#3158) by @stefan6419846
- Avoid negative seek values when reading partially broken files (#3157) by @stefan6419846

### Documentation (DOC)
- Fixed PageObject.images example usage for replacing image (#3149) by @jutoth

[Full Changelog](5.3.0...5.3.1)
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.

Improve handling of LZW decoder table overflow

1 participant