Fix heap-buffer overflow

(cherry picked from commit 2c10c1abf8ff2e88b1da04e050bb721487b73fa3)
This commit is contained in:
wk333 2024-12-17 20:24:30 +08:00 committed by openeuler-sync-bot
parent f95adbae53
commit 7982dd0075
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,30 @@
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

View File

@ -2,7 +2,7 @@
Name: giflib
Version: 5.2.2
Release: 1
Release: 2
Summary: A library and utilities for processing GIFs
License: MIT
URL: http://www.sourceforge.net/projects/giflib/
@ -15,6 +15,7 @@ Patch1:giflib_coverity.patch
# Generate HTML docs with consistent section IDs to avoid multilib difference
Patch2:giflib_html-docs-consistent-ids.patch
Patch3:CVE-2021-40633.patch
Patch4:Fix-heap-buffer-overflow.patch
BuildRequires: make xmlto gcc
BuildRequires: ImageMagick
@ -75,6 +76,9 @@ rm -f %{buildroot}/debugsourcefiles.list
%{_bindir}/gif*
%changelog
* Tue Dec 17 2024 wangkai <13474090681@163.com> - 5.2.2-2
- Fix heap-buffer overflow
* Fri Jun 21 2024 yaoxin <yao_xin001@hoperun.com> - 5.2.2-1
- Update to 5.2.2
* Fixes for CVE-2023-48161 (bsc#1217390), CVE-2022-28506 (bsc#1198880)