From d7712e453fa6051d014eeab2392532a1fcd34621 Mon Sep 17 00:00:00 2001 From: baiguo Date: Fri, 9 Aug 2024 14:53:32 +0800 Subject: [PATCH] fix CVE-2024-39134 --- fix-CVE-2024-39134.patch | 39 +++++++++++++++++++++++++++++++++++++++ zziplib.spec | 9 +++++++-- 2 files changed, 46 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..26e6519 --- /dev/null +++ b/fix-CVE-2024-39134.patch @@ -0,0 +1,39 @@ +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 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/zzip/zip.c b/zzip/zip.c +index b5b8be0..56b5966 100644 +--- a/zzip/zip.c ++++ b/zzip/zip.c +@@ -291,7 +291,7 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, struct _disk_trailer* _zz + register unsigned char* tail; + 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 + /* if the file-comment is not present, it happens +@@ -327,7 +327,7 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, struct _disk_trailer* _zz + return (0); + } + } +- else if ((*tail == 'P') && end - tail >= __sizeof(struct zzip_disk64_trailer) - 2 && ++ 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 ea7dc26..93bd5ed 100644 --- a/zziplib.spec +++ b/zziplib.spec @@ -1,11 +1,13 @@ Name: zziplib Version: 0.13.74 -Release: 1 +Release: 2 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.74.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 +40,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 @@ -69,6 +71,9 @@ This package includes help documentation and manuals related to zziplib. %{_mandir}/man3/* %changelog +* Fri Aug 9 2024 baiguo - 0.13.74-2 +- fix CVE-2024-39134 + * Tue Jul 9 2024 dillon chen - 0.13.74-1 - update to 0.13.74 -- Gitee