From 5dcc7af40422dd112c9552a58406f3ddc782d78e Mon Sep 17 00:00:00 2001 From: baiguo Date: Fri, 9 Aug 2024 15:34:23 +0800 Subject: [PATCH] fix CVE-2024-39134 (cherry picked from commit dcd55e9bc3ac603c7edc7592e765ee2127d02b75) --- fix-CVE-2024-39134.patch | 45 ++++++++++++++++++++++++++++++++++++++++ zziplib.spec | 8 +++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 fix-CVE-2024-39134.patch diff --git a/fix-CVE-2024-39134.patch b/fix-CVE-2024-39134.patch new file mode 100644 index 0000000..747e754 --- /dev/null +++ b/fix-CVE-2024-39134.patch @@ -0,0 +1,45 @@ +From 2a84ae73e93b0c1f4f12f2c58104f8327d10e41b Mon Sep 17 00:00:00 2001 +From: vlefebvre +Date: Wed, 7 Aug 2024 11:10:05 +0200 +Subject: [PATCH] fetch_disk_trailer: Don't truncate the size verif +Reference:https://github.com/gdraheim/zziplib/commit/2a84ae73e93b0c1f4f12f2c58104f8327d10e41b + +* We must check if the tail obtained have the size of the zzip_disk_trailer + struct. end - tail should be at least >= of the size but not size - 2. + Where truncated by 2 was good for pre-C99 compilers. +* Fix gdraheim#165 + +--- + zzip/zip.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/zzip/zip.c b/zzip/zip.c +index dfa1c2f..8d9bc9b 100644 +--- a/zzip/zip.c ++++ b/zzip/zip.c +@@ -293,7 +293,7 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, + for (tail = end - 1; (tail >= mapped); tail--) + { + if ((*tail == 'P') && /* quick pre-check for trailer magic */ +- end - tail >= __sizeof(struct zzip_disk_trailer) - 2 && ++ end - tail >= __sizeof(struct zzip_disk_trailer) && + zzip_disk_trailer_check_magic(tail)) + { + # ifndef ZZIP_DISK64_TRAILER +@@ -329,10 +329,9 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, + if (trailer->zz_rootseek >= filesize || (trailer->zz_rootseek + trailer->zz_rootsize) >= filesize) + return(ZZIP_CORRUPTED); + { return(0); } +- } else if ((*tail == 'P') && +- end - tail >= +- __sizeof(struct zzip_disk64_trailer) - 2 +- && zzip_disk64_trailer_check_magic(tail)) ++ } ++ else if ((*tail == 'P') && end - tail >= __sizeof(struct zzip_disk64_trailer) && ++ zzip_disk64_trailer_check_magic(tail)) + { + # ifndef ZZIP_DISK64_TRAILER + return (ZZIP_DIR_LARGEFILE); +-- +2.27.0 + diff --git a/zziplib.spec b/zziplib.spec index eb4e820..3a73c48 100644 --- a/zziplib.spec +++ b/zziplib.spec @@ -1,11 +1,12 @@ Name: zziplib Version: 0.13.72 -Release: 2 +Release: 3 Summary: Lightweight library for zip compression License: LGPLv2+ or MPLv1.1 URL: http://zziplib.sourceforge.net Source0: https://github.com/gdraheim/zziplib/archive/refs/tags/v0.13.72.tar.gz +Patch0001: fix-CVE-2024-39134.patch BuildRequires: perl-interpreter zip xmlto BuildRequires: zlib-devel SDL-devel pkgconfig autoconf automake gcc make BuildRequires: cmake @@ -38,7 +39,7 @@ BuildArch: noarch This package includes help documentation and manuals related to zziplib. %prep -%setup -q +%autosetup -p1 -n %{name}-%{version} %build %cmake -B "%{_vpath_builddir}" -DZZIP_TESTCVE=OFF @@ -68,6 +69,9 @@ This package includes help documentation and manuals related to zziplib. %{_mandir}/man3/* %changelog +* Fri Aug 9 2024 baiguo - 0.13.72-3 +- fix CVE-2024-39134 + -* Wed Jul 5 2023 dillon chen - 0.13.72-2 -- add -DZZIP_TESTCVE=OFF skip download test(curl github) -- Gitee