-
Couldn't load subscription status.
- Fork 644
fix(iff): Handle non-zero origin, protect against buffer overflows #4925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Any comments about this potentially serious bug? This was found externally via fuzzing by people looking for security issues, so I'd like to get it integrated as soon as possible. |
IffInput::read_native_tile was simply incorrect for images with nonzero data window origin. Fix! Also switch the forumulation to use spancpy rather than memcpy, to be a little more careful that we are't overwriting the presumed sizes of the buffers. And while I'm in there, I realized we can hold the mutex for less time. Signed-off-by: Larry Gritz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug in IFF image reading when handling images with non-zero data window origins and improves buffer safety through the use of span-based copying instead of raw memcpy.
- Corrects tile coordinate calculations to account for non-zero image origin offsets
- Replaces unsafe memcpy operations with spancpy for buffer overflow protection
- Optimizes mutex lock scope to reduce contention
Comments suppressed due to low confidence (1)
src/iff.imageio/iffinput.cpp:529
- After adjusting
xto be relative to the data origin (line 521), this calculation may be incorrect. Ifxis negative after adjustment,twcould be larger than intended or negative. Similarly, the comparison should likely be against the image width considering the origin. Add validation thatx >= 0and ensure width calculations account for the adjusted coordinate space.
int tw = std::min(x + static_cast<int>(m_header.tile_width),
static_cast<int>(m_header.width))
- x;
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Signed-off-by: Larry Gritz <[email protected]>
|
This fixes an important issue and has gone for a week without objection. Merging. |
d423a14
into
AcademySoftwareFoundation:main
…cademySoftwareFoundation#4925) IffInput::read_native_tile was simply incorrect for images with nonzero data window origin. Fix! Also switch the forumulation to use spancpy rather than memcpy, to be a little more careful that we are't overwriting the presumed sizes of the buffers. And while I'm in there, I realized we can hold the mutex for less time. --------- Signed-off-by: Larry Gritz <[email protected]>
…cademySoftwareFoundation#4925) IffInput::read_native_tile was simply incorrect for images with nonzero data window origin. Fix! Also switch the forumulation to use spancpy rather than memcpy, to be a little more careful that we are't overwriting the presumed sizes of the buffers. And while I'm in there, I realized we can hold the mutex for less time. --------- Signed-off-by: Larry Gritz <[email protected]>
IffInput::read_native_tile was simply incorrect for images with nonzero data window origin. Fix!
Also switch the forumulation to use spancpy rather than memcpy, to be a little more careful that we are't overwriting the presumed sizes of the buffers.
And while I'm in there, I realized we can hold the mutex for less time.