Skip to content

codecs/hdr: guard against arithmetic overflow in decode_old_rle - #3125

Open
ByGh00st wants to merge 1 commit into
image-rs:mainfrom
ByGh00st:fix/hdr-rle-arithmetic-overflow
Open

ByGh00st wants to merge 1 commit into
image-rs:mainfrom
ByGh00st:fix/hdr-rle-arithmetic-overflow

Conversation

@ByGh00st

@ByGh00st ByGh00st commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Adds arithmetic overflow protection in codecs::hdr::decode_old_rle.

Details

In decode_old_rle, run-length accumulation (x_off + rl) was performed without checked arithmetic. On 32-bit architectures or crafted streams, integer wrap-around could cause unexpected behavior or panics.

This patch replaces unchecked addition with x_off.checked_add(rl), returning DecoderError::WrongScanlineLength if an overflow condition occurs.

Backward Compatibility

  • Zero breaking changes to public APIs.
  • Valid HDR decoding behavior is completely preserved.

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.

1 participant