Commit ddc6083 for zlib
commit ddc6083ad03f3339cfb278ee346aae02053f3d63
Author: Naveed Khan <dxbnaveed.k@gmail.com>
Date: Fri Oct 23 19:06:42 2026 +0530
Fix corruption in Zip64 directory entries with file comments.
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 1d1e406..58a84bf 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -1901,6 +1901,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
if(datasize > 0)
{
char* p = NULL;
+ uLong size_comment;
if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
{
@@ -1908,7 +1909,12 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
return ZIP_BADZIPFILE;
}
- p = zi->ci.central_header + zi->ci.size_centralheader;
+ /* Insert the ZIP64 field at the end of the extra field, which is ahead
+ of the file comment, so move the comment up to make room. */
+ size_comment = (unsigned char)zi->ci.central_header[32] |
+ ((uLong)(unsigned char)zi->ci.central_header[33] << 8);
+ p = zi->ci.central_header + zi->ci.size_centralheader - size_comment;
+ memmove(p + datasize + 4, p, size_comment);
/* Add Extra Information Header for 'ZIP64 information' */
zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */