From d132ecb1402dde84ce9851bddaa6587a90014e07 Mon Sep 17 00:00:00 2001 From: wk333 <13474090681@163.com> Date: Tue, 17 Dec 2024 15:44:15 +0800 Subject: [PATCH 1/1] Fix heap-buffer overflow Refer: https://sourceforge.net/u/mmuzila/giflib/ci/fix-cve-2022-28506/ --- gif2rgb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gif2rgb.c b/gif2rgb.c index 2b4bb23..0b2e05a 100644 --- a/gif2rgb.c +++ b/gif2rgb.c @@ -337,6 +337,11 @@ static void DumpScreen2RGB(char *FileName, int OneFileFlag, GifRow = ScreenBuffer[i]; GifQprintf("\b\b\b\b%-4d", ScreenHeight - i); for (j = 0; j < ScreenWidth; j++) { + /* Check if color is within color palete */ + if (GifRow[j] >= ColorMap->ColorCount) { + GIF_EXIT(GifErrorString( + D_GIF_ERR_IMAGE_DEFECT)); + } ColorMapEntry = &ColorMap->Colors[GifRow[j]]; Buffers[0][j] = ColorMapEntry->Red; Buffers[1][j] = ColorMapEntry->Green; -- 2.33.0