summaryrefslogtreecommitdiffstats
path: root/meta/recipes-gnome/gdk-pixbuf/gdk-pixbuf/CVE-2021-46829.patch
blob: b29ab209ce64d2b9cf7e0d4340dee51b719373fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From bdf3a2630c02a63803309cf0ad4b274234c814ce Mon Sep 17 00:00:00 2001
From: Hitendra Prajapati <hprajapati@mvista.com>
Date: Tue, 9 Aug 2022 09:45:42 +0530
Subject: [PATCH] CVE-2021-46829

Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/commit/5398f04d772f7f8baf5265715696ed88db0f0512]
CVE: CVE-2021-46829
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
---
 gdk-pixbuf/io-gif-animation.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/gdk-pixbuf/io-gif-animation.c b/gdk-pixbuf/io-gif-animation.c
index d742963..9544391 100644
--- a/gdk-pixbuf/io-gif-animation.c
+++ b/gdk-pixbuf/io-gif-animation.c
@@ -364,7 +364,7 @@ composite_frame (GdkPixbufGifAnim *anim, GdkPixbufFrame *frame)
         for (i = 0; i < n_indexes; i++) {
                 guint8 index = index_buffer[i];
                 guint x, y;
-                int offset;
+                gsize offset;
 
                 if (index == frame->transparent_index)
                         continue;
@@ -374,11 +374,13 @@ composite_frame (GdkPixbufGifAnim *anim, GdkPixbufFrame *frame)
                 if (x >= anim->width || y >= anim->height)
                         continue;
 
-                offset = y * gdk_pixbuf_get_rowstride (anim->last_frame_data) + x * 4;
-                pixels[offset + 0] = frame->color_map[index * 3 + 0];
-                pixels[offset + 1] = frame->color_map[index * 3 + 1];
-                pixels[offset + 2] = frame->color_map[index * 3 + 2];
-                pixels[offset + 3] = 255;
+                if (g_size_checked_mul (&offset, gdk_pixbuf_get_rowstride (anim->last_frame_data), y) &&
+                    g_size_checked_add (&offset, offset, x * 4)) {
+                        pixels[offset + 0] = frame->color_map[index * 3 + 0];
+                        pixels[offset + 1] = frame->color_map[index * 3 + 1];
+                        pixels[offset + 2] = frame->color_map[index * 3 + 2];
+                        pixels[offset + 3] = 255;
+                }
         }
 
 out:
@@ -443,8 +445,11 @@ gdk_pixbuf_gif_anim_iter_get_pixbuf (GdkPixbufAnimationIter *anim_iter)
                         x_end = MIN (anim->last_frame->x_offset + anim->last_frame->width, anim->width);
                         y_end = MIN (anim->last_frame->y_offset + anim->last_frame->height, anim->height);
                         for (y = anim->last_frame->y_offset; y < y_end; y++) {
-                                guchar *line = pixels + y * gdk_pixbuf_get_rowstride (anim->last_frame_data) + anim->last_frame->x_offset * 4;
-                                memset (line, 0, (x_end - anim->last_frame->x_offset) * 4);
+                                gsize offset;
+                                if (g_size_checked_mul (&offset, gdk_pixbuf_get_rowstride (anim->last_frame_data), y) &&
+                                    g_size_checked_add (&offset, offset, anim->last_frame->x_offset * 4)) {
+                                         memset (pixels + offset, 0, (x_end - anim->last_frame->x_offset) * 4);
+                                }
                         }
                         break;
                 case GDK_PIXBUF_FRAME_REVERT:
-- 
2.25.1