Skip to content

fix(bmp): bomb guard, UB-safe height negation, and scanline bounds - #5371

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-bmpfixes
Open

fix(bmp): bomb guard, UB-safe height negation, and scanline bounds#5371
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-bmpfixes

Conversation

@lgritz

@lgritz lgritz commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Harden the BMP reader:

  • check_compression_ratio() rejects a tiny file with implausibly high resolutions according to the header.
  • Negate the height field in 64-bit. Since -m_dib_header.height is signed, it could lead to overflow UB when the attacker-controlled int32 height is INT32_MIN; check_open() then rejects the out-of-range value cleanly.
  • read_native_scanline() rejected y > height, allowing y == height. Should have been >= all along.

Assisted-by: Claude Code / Claude Opus 4.8

Harden the BMP reader:

- check_compression_ratio() rejects a tiny file with implausibly high
  resolutions according to the header.
- Negate the height field in 64-bit. -m_dib_header.height is signed-
  overflow UB when the attacker-controlled int32 height is INT32_MIN;
  check_open() then rejects the out-of-range value cleanly.
- read_native_scanline() rejected y > height, allowing y == height. Should
  have been `>=` all along.

Assisted-by: Claude Code / Claude Opus 4.8

Signed-off-by: Larry Gritz <lg@larrygritz.com>
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.

1 participant