Skip to content

CVE-2024-28579, CVE-2024-28582 - Fix heap buffer overflow in HDR RLE scanline reader - #55

Merged
danoli3 merged 2 commits into
masterfrom
fix/hdr-scanline-size-overflow
Aug 16, 2026
Merged

CVE-2024-28579, CVE-2024-28582 - Fix heap buffer overflow in HDR RLE scanline reader#55
danoli3 merged 2 commits into
masterfrom
fix/hdr-scanline-size-overflow

Conversation

@danoli3

@danoli3 danoli3 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

rgbe_ReadPixels_RLE()'s "not actually RLE, read flat" fallbacks passed scanline_width * num_scanlines straight into rgbe_ReadPixels()'s unsigned numpixels. scanline_width is signed — a negative value converts to a huge unsigned before the multiply, and the product was never checked for overflow either way. rgbe_RGBEToFloat(&data[x], ...) then writes past the end of the caller's scanline buffer on a crafted HDR file.

Adds rgbe_SafeScanlinePixelCount(), which rejects a negative width and checks the product fits in an unsigned, and uses it at both fallback sites.

CVE Link
CVE-2024-28579 https://nvd.nist.gov/vuln/detail/CVE-2024-28579
CVE-2024-28582 https://nvd.nist.gov/vuln/detail/CVE-2024-28582

Fixes: CVE-2024-28579
Fixes: CVE-2024-28582

…VE-2024-28582)

rgbe_ReadPixels_RLE()'s two "not RLE, read flat" fallback paths passed
`scanline_width * num_scanlines` straight into rgbe_ReadPixels()'s
`unsigned numpixels` parameter. scanline_width is a signed int; if it
is negative, the usual arithmetic conversions turn it into a huge
unsigned value before the multiply, and even for positive values the
product itself was never checked for overflow. Either way,
rgbe_ReadPixels()'s `for(x = 0; x < numpixels; x++) rgbe_RGBEToFloat(&data[x], ...)`
loop then writes far past the end of the caller's per-scanline buffer
on a crafted HDR file.

Add rgbe_SafeScanlinePixelCount(), which rejects a negative
scanline_width and checks the product fits in an unsigned before it's
used, and apply it at both fallback call sites.

CWE-787 (Out-of-bounds Write)

Fixes: CVE-2024-28579
Fixes: CVE-2024-28582
The previous commit's edit was re-serialized as UTF-8, corrupting the
file's original ISO-8859-1 "Hervé Drolon" byte sequence into a
replacement character. Restore it by converting the original file to
UTF-8 properly rather than accidentally.
@danoli3
danoli3 force-pushed the fix/hdr-scanline-size-overflow branch from 10d7654 to 0cd1eaf Compare August 16, 2026 08:29
@danoli3
danoli3 merged commit 125541b into master Aug 16, 2026
36 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.

1 participant