From f7637e1d0db601cf9cbe958e1125b4c6d3a20a61 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Wed, 24 May 2023 22:11:08 +0800 Subject: [PATCH] Fix CVE-2023-1999 --- libwebp-1.3.0-CVE-2023-1999.patch | 52 +++++++++++++++++++++++++++++++ libwebp.spec | 6 +++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 libwebp-1.3.0-CVE-2023-1999.patch diff --git a/libwebp-1.3.0-CVE-2023-1999.patch b/libwebp-1.3.0-CVE-2023-1999.patch new file mode 100644 index 0000000..65c2cf7 --- /dev/null +++ b/libwebp-1.3.0-CVE-2023-1999.patch @@ -0,0 +1,52 @@ +From a486d800b60d0af4cc0836bf7ed8f21e12974129 Mon Sep 17 00:00:00 2001 +From: James Zern +Date: Wed, 22 Feb 2023 22:15:47 -0800 +Subject: [PATCH] EncodeAlphaInternal: clear result->bw on error + +This avoids a double free should the function fail prior to +VP8BitWriterInit() and a previous trial result's buffer carried over. +Previously in ApplyFiltersAndEncode() trial.bw (with a previous +iteration's buffer) would be freed, followed by best.bw pointing to the +same buffer. + +Since: +187d379d add a fallback to ALPHA_NO_COMPRESSION + +In addition, check the return value of VP8BitWriterInit() in this +function. + +Bug: webp:603 +Change-Id: Ic258381ee26c8c16bc211d157c8153831c8c6910 +--- + src/enc/alpha_enc.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/enc/alpha_enc.c b/src/enc/alpha_enc.c +index f7c02690e3..7d205586fe 100644 +--- a/src/enc/alpha_enc.c ++++ b/src/enc/alpha_enc.c +@@ -13,6 +13,7 @@ + + #include + #include ++#include + + #include "src/enc/vp8i_enc.h" + #include "src/dsp/dsp.h" +@@ -148,6 +149,7 @@ static int EncodeAlphaInternal(const uint8_t* const data, int width, int height, + } + } else { + VP8LBitWriterWipeOut(&tmp_bw); ++ memset(&result->bw, 0, sizeof(result->bw)); + return 0; + } + } +@@ -162,7 +164,7 @@ static int EncodeAlphaInternal(const uint8_t* const data, int width, int height, + header = method | (filter << 2); + if (reduce_levels) header |= ALPHA_PREPROCESSED_LEVELS << 4; + +- VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size); ++ if (!VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size)) ok = 0; + ok = ok && VP8BitWriterAppend(&result->bw, &header, ALPHA_HEADER_LEN); + ok = ok && VP8BitWriterAppend(&result->bw, output, output_size); + diff --git a/libwebp.spec b/libwebp.spec index 445f32d..05fcd91 100644 --- a/libwebp.spec +++ b/libwebp.spec @@ -1,4 +1,4 @@ -%define anolis_release 4 +%define anolis_release 5 %global _hardened_build 1 Name: libwebp @@ -12,6 +12,7 @@ Source1: libwebp_jni_example.java Patch0: libwebp-freeglut.patch Patch2: libwebp-cmakedir.patch Patch3: libwebp-rpath.patch +Patch4: libwebp-1.3.0-CVE-2023-1999.patch BuildRequires: swig BuildRequires: cmake gcc @@ -155,6 +156,9 @@ cp swig/*.jar swig/*.so %{buildroot}/%{_libdir}/%{name}-java/ %doc README.md PATENTS NEWS AUTHORS %changelog +* Wed May 24 2023 Funda Wang - 1.3.0-5 +- Fix CVE-2023-1999 + * Thu Apr 13 2023 Xuchun Shang - 1.3.0-4 - Optimize the spec -- Gitee