Skip to content
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

fix heap-buffer-overflow in file src/gif.imageio/gifinput.cpp, line 368 #3841

Merged
merged 3 commits into from
May 17, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/gif.imageio/gifinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,13 @@ bool
GIFInput::read_subimage_data()
{
GifColorType* colormap = NULL;
int colormap_count;
if (m_gif_file->Image.ColorMap) { // local colormap
colormap = m_gif_file->Image.ColorMap->Colors;
colormap_count = m_gif_file->Image.ColorMap->ColorCount;
} else if (m_gif_file->SColorMap) { // global colormap
colormap = m_gif_file->SColorMap->Colors;
colormap_count = m_gif_file->SColorMap->ColorCount;
lgritz marked this conversation as resolved.
Show resolved Hide resolved
} else {
errorf("Neither local nor global colormap present.");
return false;
Expand Down Expand Up @@ -361,6 +364,12 @@ GIFInput::read_subimage_data()
+ (interlacing ? decode_line_number(wy, window_height) : wy);
if (0 <= y && y < m_spec.height) {
for (int wx = 0; wx < window_width; wx++) {
if (fscanline[wx] >= colormap_count) {
errorfmt(
"Possible corruption: Encoded value {:d} @ ({},{}) exceeds palette size {}\n",
fscanline[wx], wx, y, colormap_count);
return false;
lgritz marked this conversation as resolved.
Show resolved Hide resolved
}
int x = window_left + wx;
int idx = m_spec.nchannels * (y * m_spec.width + x);
if (0 <= x && x < m_spec.width
Expand Down