From 72b6d78e31fb53f7c5bd8ab012d0d07403a13cb4 Mon Sep 17 00:00:00 2001 From: Soju Tanaka Date: Wed, 4 Mar 2026 17:13:39 +0900 Subject: [PATCH] Find end-of-central-directory record (EOCD) signature in the last 0xFFFF bytes + the size of EOCD --- contrib/minizip/unzip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index d7ff21cb5..8cacde144 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c @@ -110,6 +110,8 @@ #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) +#define SIZEEOCD (0x16) +#define SIZEZIP64EOCDLOCATOR (0x14) const char unz_copyright[] = @@ -326,7 +328,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uMaxBack= SIZEEOCD + 0xffff; /* EOCD record + maximum size of global comment */ ZPOS64_T uPosFound=CENTRALDIRINVALID; if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) @@ -387,7 +389,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uMaxBack= SIZEZIP64EOCDLOCATOR + SIZEEOCD + 0xffff; /* EOCD locator/record + maximum size of global comment */ ZPOS64_T uPosFound=CENTRALDIRINVALID; uLong uL; ZPOS64_T relativeOffset;