|
| 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 |
0 commit comments