From 6fba2bcead4789805d33258cd97fee5402d2de17 Mon Sep 17 00:00:00 2001 From: tangyuchen Date: Tue, 9 Apr 2024 11:37:39 +0800 Subject: [PATCH] file: fix a memory leak problem Signed-off-by: tangyuchen (cherry picked from commit b1aa6f1e5f5181d15999ab12afe7336fb4efb318) --- 0003-Avoid-leak-in-zlib-clusterfuzz.patch | 28 +++++++++++++++++++++++ file.spec | 6 ++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 0003-Avoid-leak-in-zlib-clusterfuzz.patch diff --git a/0003-Avoid-leak-in-zlib-clusterfuzz.patch b/0003-Avoid-leak-in-zlib-clusterfuzz.patch new file mode 100644 index 0000000..c78cfa9 --- /dev/null +++ b/0003-Avoid-leak-in-zlib-clusterfuzz.patch @@ -0,0 +1,28 @@ +From 54466c8b4cc07eaabaa2602bdf6b858bfe82e3d1 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Tue, 20 Sep 2022 21:11:00 +0000 +Subject: [PATCH] Avoid leak in zlib (clusterfuzz) + +--- + src/compress.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/compress.c b/src/compress.c +index 9f65e4f..fb9b55e 100644 +--- a/src/compress.c ++++ b/src/compress.c +@@ -578,8 +578,10 @@ uncompresszlib(const unsigned char *old, unsigned char **newch, + goto err; + + rc = inflate(&z, Z_SYNC_FLUSH); +- if (rc != Z_OK && rc != Z_STREAM_END) ++ if (rc != Z_OK && rc != Z_STREAM_END) { ++ inflateEnd(&z); + goto err; ++ } + + *n = CAST(size_t, z.total_out); + rc = inflateEnd(&z); +-- +2.33.0 + diff --git a/file.spec b/file.spec index 23e69e5..81f8d50 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file Version: 5.41 -Release: 3 +Release: 4 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -9,6 +9,7 @@ Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz Patch1: 0001-file-localmagic.patch Patch2: 0002-fix-typos-fxlb.patch Patch3: CVE-2022-48554.patch +Patch4: 0003-Avoid-leak-in-zlib-clusterfuzz.patch Requires: %{name}-libs = %{version}-%{release} BuildRequires: autoconf automake libtool zlib-devel make @@ -132,6 +133,9 @@ make -C tests check %{python3_sitelib}/__pycache__/* %changelog +* Tue Apr 9 2024 tangyuchen - 5.41-4 +- fix a memory leak problem + * Wed Aug 23 2023 liningjie - 5.41-3 - fix CVE-2022-48554 -- Gitee