Skip to content

Commit d0eb3f3

Browse files
[AUTO-CHERRYPICK] Patch gdk-pixbuf2 for CVE-2022-48622. - branch main (#10508)
Co-authored-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
1 parent bec544d commit d0eb3f3

2 files changed

Lines changed: 117 additions & 1 deletion

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
From 00c071dd11f723ca608608eef45cb1aa98da89cc Mon Sep 17 00:00:00 2001
2+
From: Benjamin Gilbert <bgilbert@backtick.net>
3+
Date: Tue, 30 Apr 2024 07:26:54 -0500
4+
Subject: [PATCH 1/3] ANI: Reject files with multiple anih chunks
5+
6+
An anih chunk causes us to initialize a bunch of state, which we only
7+
expect to do once per file.
8+
9+
Fixes: #202
10+
Fixes: CVE-2022-48622
11+
---
12+
gdk-pixbuf/io-ani.c | 9 +++++++++
13+
1 file changed, 9 insertions(+)
14+
15+
diff --git a/gdk-pixbuf/io-ani.c b/gdk-pixbuf/io-ani.c
16+
index c6c4642cf4..a78ea7ace4 100644
17+
--- a/gdk-pixbuf/io-ani.c
18+
+++ b/gdk-pixbuf/io-ani.c
19+
@@ -295,6 +295,15 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
20+
21+
if (context->chunk_id == TAG_anih)
22+
{
23+
+ if (context->animation)
24+
+ {
25+
+ g_set_error_literal (error,
26+
+ GDK_PIXBUF_ERROR,
27+
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
28+
+ _("Invalid header in animation"));
29+
+ return FALSE;
30+
+ }
31+
+
32+
context->HeaderSize = read_int32 (context);
33+
context->NumFrames = read_int32 (context);
34+
context->NumSteps = read_int32 (context);
35+
--
36+
GitLab
37+
38+
39+
From d52134373594ff76614fb415125b0d1c723ddd56 Mon Sep 17 00:00:00 2001
40+
From: Benjamin Gilbert <bgilbert@backtick.net>
41+
Date: Tue, 30 Apr 2024 07:13:37 -0500
42+
Subject: [PATCH 2/3] ANI: Reject files with multiple INAM or IART chunks
43+
44+
There should be at most one chunk each. These would cause memory leaks
45+
otherwise.
46+
---
47+
gdk-pixbuf/io-ani.c | 4 ++--
48+
1 file changed, 2 insertions(+), 2 deletions(-)
49+
50+
diff --git a/gdk-pixbuf/io-ani.c b/gdk-pixbuf/io-ani.c
51+
index a78ea7ace4..8e8414117c 100644
52+
--- a/gdk-pixbuf/io-ani.c
53+
+++ b/gdk-pixbuf/io-ani.c
54+
@@ -445,7 +445,7 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
55+
}
56+
else if (context->chunk_id == TAG_INAM)
57+
{
58+
- if (!context->animation)
59+
+ if (!context->animation || context->title)
60+
{
61+
g_set_error_literal (error,
62+
GDK_PIXBUF_ERROR,
63+
@@ -472,7 +472,7 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
64+
}
65+
else if (context->chunk_id == TAG_IART)
66+
{
67+
- if (!context->animation)
68+
+ if (!context->animation || context->author)
69+
{
70+
g_set_error_literal (error,
71+
GDK_PIXBUF_ERROR,
72+
--
73+
GitLab
74+
75+
76+
From 91b8aa5cd8a0eea28acb51f0e121827ca2e7eb78 Mon Sep 17 00:00:00 2001
77+
From: Benjamin Gilbert <bgilbert@backtick.net>
78+
Date: Tue, 30 Apr 2024 08:17:25 -0500
79+
Subject: [PATCH 3/3] ANI: Validate anih chunk size
80+
81+
Before reading a chunk, we verify that enough bytes are available to match
82+
the chunk size declared by the file. However, uniquely, the anih chunk
83+
loader doesn't verify that this size matches the number of bytes it
84+
actually intends to read. Thus, if the chunk size is too small and the
85+
file ends in the middle of the chunk, we populate some context fields with
86+
stack garbage. (But we'd still fail later on because the file doesn't
87+
contain any images.) Fix this.
88+
---
89+
gdk-pixbuf/io-ani.c | 8 ++++++++
90+
1 file changed, 8 insertions(+)
91+
92+
diff --git a/gdk-pixbuf/io-ani.c b/gdk-pixbuf/io-ani.c
93+
index 8e8414117c..cfafd7b196 100644
94+
--- a/gdk-pixbuf/io-ani.c
95+
+++ b/gdk-pixbuf/io-ani.c
96+
@@ -295,6 +295,14 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
97+
98+
if (context->chunk_id == TAG_anih)
99+
{
100+
+ if (context->chunk_size < 36)
101+
+ {
102+
+ g_set_error_literal (error,
103+
+ GDK_PIXBUF_ERROR,
104+
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
105+
+ _("Malformed chunk in animation"));
106+
+ return FALSE;
107+
+ }
108+
if (context->animation)
109+
{
110+
g_set_error_literal (error,
111+
--
112+
GitLab

SPECS/gdk-pixbuf2/gdk-pixbuf2.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
Summary: An image loading library
33
Name: gdk-pixbuf2
44
Version: 2.40.0
5-
Release: 5%{?dist}
5+
Release: 6%{?dist}
66
License: LGPLv2+
77
Vendor: Microsoft Corporation
88
Distribution: Mariner
99
URL: https://gitlab.gnome.org/GNOME/gdk-pixbuf
1010
Source0: https://download.gnome.org/sources/gdk-pixbuf/2.40/gdk-pixbuf-%{version}.tar.xz
11+
Patch0: CVE-2022-48622.patch
1112
BuildRequires: gettext
1213
BuildRequires: gtk-doc
1314
BuildRequires: jasper-devel
@@ -116,6 +117,9 @@ gdk-pixbuf-query-loaders-%{__isa_bits} --update-cache
116117
%{_datadir}/installed-tests
117118

118119
%changelog
120+
* Thu Sep 19 2024 Sumedh Sharma <sumsharma@microsoft.com> - 2.40.0-6
121+
- Add patch for CVE-2022-48622
122+
119123
* Fri Mar 31 2023 Pawel Winogrodzki <pawelwi@microsoft.com> - 2.40.0-5
120124
- Bumping release to re-build with newer 'libtiff' libraries.
121125

0 commit comments

Comments
 (0)