Skip to content

fix(lzma2): prevent undefined bit shift overflow in dictionary calculation#456

Merged
bodgit merged 1 commit into
bodgit:mainfrom
hobeone:fix/lzma2-shift
May 22, 2026
Merged

fix(lzma2): prevent undefined bit shift overflow in dictionary calculation#456
bodgit merged 1 commit into
bodgit:mainfrom
hobeone:fix/lzma2-shift

Conversation

@hobeone
Copy link
Copy Markdown
Contributor

@hobeone hobeone commented May 22, 2026

This was flagged by an LLM review - but it seems to make sense given the format described in the link below.

  • Validate that the LZMA2 dictionary property byte p[0] is <= 40 (maximum valid dictionary size of 4GB) in NewReader before calculating DictCap.
  • Prevents an undefined bit shift overflow during runtime calculation when p[0] > 40.
  • Source: https://en.wikipedia.org/wiki/LZMA#LZMA2_format

@coveralls
Copy link
Copy Markdown

coveralls commented May 22, 2026

Coverage Status

coverage: 75.131% (+0.2%) from 74.939% — hobeone:fix/lzma2-shift into bodgit:main

@hobeone hobeone force-pushed the fix/lzma2-shift branch 2 times, most recently from 47b3aff to d50c41c Compare May 22, 2026 20:52
…ation

- Validate that the LZMA2 dictionary property byte p[0] is <= 40 (maximum valid dictionary size of 4GB) in NewReader before calculating DictCap.
- Prevents an undefined bit shift overflow during runtime calculation when p[0] > 40.
- Source: https://en.wikipedia.org/wiki/LZMA#LZMA2_format
@bodgit bodgit force-pushed the fix/lzma2-shift branch from d50c41c to d10f20c Compare May 22, 2026 23:44
@bodgit bodgit merged commit 8d9854b into bodgit:main May 22, 2026
4 checks passed
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.

3 participants