CVE-2024-28579, CVE-2024-28582 - Fix heap buffer overflow in HDR RLE scanline reader - #55
Merged
Merged
Conversation
…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
force-pushed
the
fix/hdr-scanline-size-overflow
branch
from
August 16, 2026 08:29
10d7654 to
0cd1eaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rgbe_ReadPixels_RLE()'s "not actually RLE, read flat" fallbacks passedscanline_width * num_scanlinesstraight intorgbe_ReadPixels()'sunsigned numpixels.scanline_widthis 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 anunsigned, and uses it at both fallback sites.Fixes: CVE-2024-28579
Fixes: CVE-2024-28582