summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2024-01-11 22:00:54 +0000
committerCopybara-Service <copybara-worker@google.com>2024-01-11 14:11:44 -0800
commit956936c53cb6169f2b97e009bfaefd66da227ab6 (patch)
tree0702adf6110826b90353ece1864280eaa0d56cca
parent40e35a76af71511ee701001df5bc1ba216472d67 (diff)
downloadzlib-956936c53cb6169f2b97e009bfaefd66da227ab6.tar.gz
[zlib] Add missing .patch files for diffs against upstream minizip
To make sure we don't lose them in future updates, add missing .patch files for local modifications to minizip. Bug: 1517633, 812400 Change-Id: I227106eb93009a300ceede557b1827e60920899b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185350 Reviewed-by: Adenilson Cavalcanti <cavalcantii@chromium.org> Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org> Cr-Commit-Position: refs/heads/main@{#1246092} NOKEYCHECK=True GitOrigin-RevId: 350c672ef5f3a6d2361f6e8d9df3bebedfc91a0c
-rw-r--r--contrib/minizip/README.chromium10
-rw-r--r--patches/0000-build.patch13
-rw-r--r--patches/0014-minizip-unzip-with-incorrect-size.patch34
-rw-r--r--patches/0015-minizip-unzip-enable-decryption.patch39
-rw-r--r--patches/0016-minizip-parse-unicode-path-extra-field.patch159
5 files changed, 255 insertions, 0 deletions
diff --git a/contrib/minizip/README.chromium b/contrib/minizip/README.chromium
index b13de23..28d8334 100644
--- a/contrib/minizip/README.chromium
+++ b/contrib/minizip/README.chromium
@@ -13,9 +13,19 @@ Minizip provides API on top of zlib that can enumerate and extract ZIP archive
files. See minizip.md for chromium build instructions.
Local Modifications:
+- Fixed uncompressing files with wrong uncompressed size set
+ crrev.com/268940
+ 0014-minizip-unzip-with-incorrect-size.patch
+
+- Enable traditional PKWARE decryption in zlib/contrib/minizip
+ Correct the value of rest_read_compressed when decompressing an encrypted
+ zip. (crrev.com/580862)
+ 0015-minizip-unzip-enable-decryption.patch
+
- Add parsing of the 'Info-ZIP Unicode Path Extra Field' as described in
https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT section 4.6.9.
(see crrev.com/1002476)
+ 0016-minizip-parse-unicode-path-extra-field.patch
- Check for overly long filename, comment, or extra field in
zipOpenNewFileInZip4_64 (crbug.com/1470539).
diff --git a/patches/0000-build.patch b/patches/0000-build.patch
index 6119f09..4497158 100644
--- a/patches/0000-build.patch
+++ b/patches/0000-build.patch
@@ -1,3 +1,16 @@
+diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
+index 7f5c191b2afd1..543910b5e118a 100644
+--- a/contrib/minizip/ioapi.c
++++ b/contrib/minizip/ioapi.c
+@@ -14,7 +14,7 @@
+ #define _CRT_SECURE_NO_WARNINGS
+ #endif
+
+-#if defined(__APPLE__) || defined(IOAPI_NO_64)
++#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64)
+ // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+ #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
+ #define FTELLO_FUNC(stream) ftello(stream)
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
index 274f39eb1dd2..246ceb91a139 100644
--- a/contrib/minizip/iowin32.c
diff --git a/patches/0014-minizip-unzip-with-incorrect-size.patch b/patches/0014-minizip-unzip-with-incorrect-size.patch
new file mode 100644
index 0000000..622fb8a
--- /dev/null
+++ b/patches/0014-minizip-unzip-with-incorrect-size.patch
@@ -0,0 +1,34 @@
+commit 764f0715d75c8d49339aa73d0ee2feb75d63473f
+Author: joaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>
+Date: Wed May 7 20:53:02 2014 +0000
+
+ Fixed uncompressing files with wrong uncompressed size set.
+
+ A zip file carries some metadata for each archived file, including the total
+ uncompressed size. If that size was incorrect, therefore the compressed file
+ being different in size when unpacking, the minizip code would fail with a
+ CRC error. Every other zip utility handles these files, so should the minizip
+ code for safety sake.
+
+ BUG=359516
+
+ Review URL: https://codereview.chromium.org/222243003
+
+ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268940 0039d316-1c4b-4281-b951-d872f2087c98
+
+diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
+index 22481a2d6c4c6..af59b8029443c 100644
+--- a/third_party/zlib/contrib/minizip/unzip.c
++++ b/third_party/zlib/contrib/minizip/unzip.c
+@@ -1705,11 +1705,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
+
+ pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
+- (!(pfile_in_zip_read_info->raw)))
+- pfile_in_zip_read_info->stream.avail_out =
+- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+-
+ if ((len>pfile_in_zip_read_info->rest_read_compressed+
+ pfile_in_zip_read_info->stream.avail_in) &&
+ (pfile_in_zip_read_info->raw))
diff --git a/patches/0015-minizip-unzip-enable-decryption.patch b/patches/0015-minizip-unzip-enable-decryption.patch
new file mode 100644
index 0000000..b60ea2c
--- /dev/null
+++ b/patches/0015-minizip-unzip-enable-decryption.patch
@@ -0,0 +1,39 @@
+commit f3ace98803035b8425d127fb3d874dafe0b9475a
+Author: Che-yu Wu <cheyuw@google.com>
+Date: Mon Aug 6 14:09:22 2018 +0000
+
+ Enable traditional PKWARE decryption in zlib/contrib/minizip.
+
+ Remove the #define which enables NOUNCRYPT by default.
+ Correct the value of rest_read_compressed when decompressing an encrypted zip.
+
+ Bug: crbug.com/869541
+ Change-Id: Ia86c1d234a8193f405147d35ad05c29fe86f812d
+ Reviewed-on: https://chromium-review.googlesource.com/1161109
+ Reviewed-by: Chris Blume <cblume@chromium.org>
+ Commit-Queue: Che-yu Wu <cheyuw@google.com>
+ Cr-Commit-Position: refs/heads/master@{#580862}
+
+diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
+index 199b4723fcfcf..e8b2bc5c766c8 100644
+--- a/third_party/zlib/contrib/minizip/unzip.c
++++ b/third_party/zlib/contrib/minizip/unzip.c
+@@ -68,10 +68,6 @@
+ #include <stdlib.h>
+ #include <string.h>
+
+-#ifndef NOUNCRYPT
+- #define NOUNCRYPT
+-#endif
+-
+ #include "zlib.h"
+ #include "unzip.h"
+
+@@ -1630,6 +1626,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+ zdecode(s->keys,s->pcrc_32_tab,source[i]);
+
+ s->pfile_in_zip_read->pos_in_zipfile+=12;
++ s->pfile_in_zip_read->rest_read_compressed-=12;
+ s->encrypted=1;
+ }
+ # endif
diff --git a/patches/0016-minizip-parse-unicode-path-extra-field.patch b/patches/0016-minizip-parse-unicode-path-extra-field.patch
new file mode 100644
index 0000000..b1c10b8
--- /dev/null
+++ b/patches/0016-minizip-parse-unicode-path-extra-field.patch
@@ -0,0 +1,159 @@
+commit c8834821f452a3d424edd0ed2a1e9ceeda38d0ea
+Author: Alex Danilo <adanilo@chromium.org>
+Date: Thu May 12 03:29:52 2022 +0000
+
+ Extract: Parse Unicode Path Extra field in minizip
+
+ Adds parsing of the Info-ZIP Extra field which overrides the
+ file name in the File Header only if the CRC in the extra field
+ is a CRC of the file name in the File Header.
+
+ See https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
+ section 4.6.9 for reference.
+
+ Also tidied up some whitespace indent.
+
+ Bug: 953256, 953599
+ Tests: Manually tested, auto test in follow on CL
+ Change-Id: I1283dcb88a203c3bb56c1d9c504035a2e51aecbd
+ Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3641742
+ Reviewed-by: Noel Gordon <noel@chromium.org>
+ Commit-Queue: Alex Danilo <adanilo@chromium.org>
+ Cr-Commit-Position: refs/heads/main@{#1002476}
+
+diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
+index e8b2bc5c766c8..0a1d8b4fe2cf7 100644
+--- a/third_party/zlib/contrib/minizip/unzip.c
++++ b/third_party/zlib/contrib/minizip/unzip.c
+@@ -1023,46 +1023,102 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+ while(acc < file_info.size_file_extra)
+ {
+ uLong headerId;
+- uLong dataSize;
++ uLong dataSize;
+
+ if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
+ err=UNZ_ERRNO;
+-
++
+ /* ZIP64 extra fields */
+ if (headerId == 0x0001)
+ {
+- uLong uL;
+-
+- if(file_info.uncompressed_size == MAXU32)
+- {
+- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+- err=UNZ_ERRNO;
+- }
+-
+- if(file_info.compressed_size == MAXU32)
+- {
+- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+- err=UNZ_ERRNO;
+- }
+-
+- if(file_info_internal.offset_curfile == MAXU32)
+- {
+- /* Relative Header offset */
+- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+- err=UNZ_ERRNO;
+- }
+-
+- if(file_info.disk_num_start == MAXU32)
+- {
+- /* Disk Start Number */
+- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+- err=UNZ_ERRNO;
+- }
++ uLong uL;
++
++ if(file_info.uncompressed_size == MAXU32)
++ {
++ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
++ err=UNZ_ERRNO;
++ }
++
++ if(file_info.compressed_size == MAXU32)
++ {
++ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
++ err=UNZ_ERRNO;
++ }
++
++ if(file_info_internal.offset_curfile == MAXU32)
++ {
++ /* Relative Header offset */
++ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
++ err=UNZ_ERRNO;
++ }
++
++ if(file_info.disk_num_start == MAXU32)
++ {
++ /* Disk Start Number */
++ if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
++ err=UNZ_ERRNO;
++ }
+
+ }
++ else if (headerId == 0x7075) /* Info-ZIP Unicode Path Extra Field */
++ {
++ int version = 0;
++
++ if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK)
++ {
++ err = UNZ_ERRNO;
++ }
++ if (version != 1)
++ {
++ if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0)
++ {
++ err = UNZ_ERRNO;
++ }
++ }
++ else
++ {
++ uLong uCrc, uHeaderCrc, fileNameSize;
++
++ if (unz64local_getLong(&s->z_filefunc, s->filestream, &uCrc) != UNZ_OK)
++ {
++ err = UNZ_ERRNO;
++ }
++ uHeaderCrc = crc32(0, (const unsigned char *)szFileName, file_info.size_filename);
++ fileNameSize = dataSize - (2 * sizeof (short) + 1);
++ /* Check CRC against file name in the header. */
++ if (uHeaderCrc != uCrc)
++ {
++ if (ZSEEK64(s->z_filefunc, s->filestream, fileNameSize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
++ {
++ err = UNZ_ERRNO;
++ }
++ }
++ else
++ {
++ uLong uSizeRead;
++
++ if (fileNameSize < fileNameBufferSize)
++ {
++ *(szFileName + fileNameSize) = '\0';
++ uSizeRead = fileNameSize;
++ }
++ else
++ {
++ uSizeRead = fileNameBufferSize;
++ }
++ if ((fileNameSize > 0) && (fileNameBufferSize > 0))
++ {
++ if (ZREAD64(s->z_filefunc, s->filestream, szFileName, uSizeRead) != uSizeRead)
++ {
++ err = UNZ_ERRNO;
++ }
++ }
++ }
++ }
++ }
+ else
+ {
+ if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)