gdk-pixbuf: fix CVE-2020-29385

Backport patch from
bdd3acbd48

image file in upstream patch is for test purpose only, it cause error during
do_patch so drop it:
File tests/test-images/fail/hang_114.gif: git binary diffs are not supported.

(From OE-Core rev: 7cd401b7c60dba91f6fb10395ab4a10a267cf23d)

Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Lee Chee Yang
2020-12-30 17:01:40 +08:00
committed by Richard Purdie
parent b9a5c512bc
commit ee867453ff
2 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
From bdd3acbd48a575d418ba6bf1b32d7bda2fae1c81 Mon Sep 17 00:00:00 2001
From: Robert Ancell <robert.ancell@canonical.com>
Date: Mon, 30 Nov 2020 12:26:12 +1300
Subject: [PATCH 02/13] gif: Fix LZW decoder accepting invalid LZW code.
The code value after a reset wasn't being validated, which means we would
accept invalid codes. This could cause an infinite loop in the decoder.
Fixes CVE-2020-29385
Fixes https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/164
Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/commit/bdd3acbd48a575d418ba6bf1b32d7bda2fae1c81]
CVE: CVE-2020-29385
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
---
gdk-pixbuf/lzw.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
create mode 100644 tests/test-images/fail/hang_114.gif
diff --git a/gdk-pixbuf/lzw.c b/gdk-pixbuf/lzw.c
index 9e052a6f7..105daf2b1 100644
--- a/gdk-pixbuf/lzw.c
+++ b/gdk-pixbuf/lzw.c
@@ -195,19 +195,20 @@ lzw_decoder_feed (LZWDecoder *self,
if (self->last_code != self->clear_code && self->code_table_size < MAX_CODES) {
if (self->code < self->code_table_size)
add_code (self, self->code);
- else if (self->code == self->code_table_size)
+ else
add_code (self, self->last_code);
- else {
- /* Invalid code received - just stop here */
- self->last_code = self->eoi_code;
- return output_length;
- }
/* When table is full increase code size */
if (self->code_table_size == (1 << self->code_size) && self->code_size < LZW_CODE_MAX)
self->code_size++;
}
+ /* Invalid code received - just stop here */
+ if (self->code >= self->code_table_size) {
+ self->last_code = self->eoi_code;
+ return output_length;
+ }
+
/* Convert codeword into indexes */
n_written += write_indexes (self, output + n_written, output_length - n_written);
}
--
2.25.1

View File

@@ -24,6 +24,7 @@ SRC_URI = "${GNOME_MIRROR}/${BPN}/${MAJ_VER}/${BPN}-${PV}.tar.xz \
file://0004-Do-not-run-tests-when-building.patch \
file://0006-Build-thumbnailer-and-tests-also-in-cross-builds.patch \
file://missing-test-data.patch \
file://CVE-2020-29385.patch \
"
SRC_URI_append_class-target = " \