Skip to content

Commit bc8732f

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update zlib to 1.4-401d185
PR-URL: #67689 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ebad21b commit bc8732f

6 files changed

Lines changed: 66 additions & 13 deletions

File tree

‎deps/zlib/contrib/minizip/unzip.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,14 +1054,16 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
10541054
/* dataSize includes version (1 byte), uCrc (4 bytes), and
10551055
* the filename data. If it's too small, fileNameSize below
10561056
* would overflow. */
1057-
err = UNZ_ERRNO;
1058-
break;
1057+
if (ZSEEK64(s->z_filefunc, s->filestream, dataSize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
1058+
{
1059+
err = UNZ_ERRNO;
1060+
}
10591061
}
10601062
else if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK)
10611063
{
10621064
err = UNZ_ERRNO;
10631065
}
1064-
if (version != 1)
1066+
else if (version != 1)
10651067
{
10661068
if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0)
10671069
{

‎deps/zlib/contrib/tests/utils_unittest.cc‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,15 @@ TEST(ZlibTest, ZipUnicodePathExtraSizeFilenameOverflow) {
14381438
base::FilePath zip_file = TestDataDir().AppendASCII("unicode_path_extra_overflow.zip");
14391439
unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
14401440
ASSERT_NE(uzf, nullptr);
1441-
EXPECT_EQ(unzGoToFirstFile(uzf), UNZ_ERRNO);
1441+
1442+
char name[100];
1443+
unz_file_info file_info;
1444+
ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK);
1445+
// The bad Unicode Path Extra Field should be ignored, and we get the regular
1446+
// filename.
1447+
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr,
1448+
0, nullptr, 0), UNZ_OK);
1449+
ASSERT_EQ(std::string(name), "\xc8\xfe \xc8\xfe\xc8\xfe.txt");
14421450
EXPECT_EQ(unzClose(uzf), UNZ_OK);
14431451
}
14441452

@@ -1482,6 +1490,34 @@ TEST(ZlibTest, ZipUnicodePathExtra) {
14821490
EXPECT_EQ(unzClose(uzf), UNZ_OK);
14831491
}
14841492

1493+
TEST(ZlibTest, ShortZipUnicodePathExtra) {
1494+
base::FilePath zip_file = TestDataDir().AppendASCII("short_unicode_path_extra.zip");
1495+
unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
1496+
ASSERT_NE(uzf, nullptr);
1497+
1498+
char name[100];
1499+
unz_file_info file_info;
1500+
1501+
ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK);
1502+
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr,
1503+
0, nullptr, 0), UNZ_OK);
1504+
ASSERT_EQ(std::string(name), "receipt.txt");
1505+
1506+
// The "decoy.dat" entry has an invalid (too short) Unicode Path Extra Field.
1507+
// Ignore the extra field rather than erroring out.
1508+
ASSERT_EQ(unzGoToNextFile(uzf), UNZ_OK);
1509+
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr,
1510+
0, nullptr, 0), UNZ_OK);
1511+
ASSERT_EQ(std::string(name), "decoy.dat");
1512+
1513+
ASSERT_EQ(unzGoToNextFile(uzf), UNZ_OK);
1514+
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr,
1515+
0, nullptr, 0), UNZ_OK);
1516+
ASSERT_EQ(std::string(name), "malware.exe");
1517+
1518+
EXPECT_EQ(unzClose(uzf), UNZ_OK);
1519+
}
1520+
14851521
TEST(ZlibTest, ZipEncryptionFlagMismatch) {
14861522
// Test archive created with info-zip:
14871523
// $ echo -n a > a && zip -P a -k a.zip a
1.36 KB
Binary file not shown.

‎deps/zlib/google/test_data.filelist‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test/data/enc_flag_mismatch.zip
2323
test/data/evil.zip
2424
test/data/evil_via_absolute_file_name.zip
2525
test/data/evil_via_invalid_utf8.zip
26+
test/data/short_unicode_path_extra.zip
2627
test/data/symlink_absolute_path.zip
2728
test/data/symlink_duplicate_link.zip
2829
test/data/symlink_evil_relative_path.zip

‎deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ Date: Mon Apr 27 13:24:27 2026 +0200
9090
Change-Id: I06e6c8a8ff8baa729b10a67a998f8804803ae6cd
9191
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7797172
9292

93+
commit 14964355aff9695897f7a2e06a4af2c4e25b71d5
94+
Author: Hans Wennborg <hans@chromium.org>
95+
Date: Wed Sep 16 15:45:40 2026 +0200
96+
97+
[minizip] Ignore invalid Unicode Path Extra Fields rather than erroring
98+
99+
To match what other extractors do.
100+
101+
Bug: 553273868
102+
Change-Id: Ia5d64fb92d2abe5eba1e74f7180688a7a4362987
103+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8418328
104+
93105
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
94106
index fb5eb0bf0f852..c15f4484f75f7 100644
95107
--- a/third_party/zlib/contrib/minizip/unzip.c
@@ -102,7 +114,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
102114
#include <stdio.h>
103115
#include <stdlib.h>
104116
#include <string.h>
105-
@@ -195,6 +196,26 @@ typedef struct
117+
@@ -195,6 +196,26 @@
106118
Reads a long in LSB order from the given gz_stream. Sets
107119
*/
108120

@@ -129,7 +141,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
129141
local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
130142
voidpf filestream,
131143
uLong *pX) {
132-
@@ -780,6 +801,10 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
144+
@@ -836,6 +857,10 @@
133145
uLong uMagic;
134146
long lSeek=0;
135147
uLong uL;
@@ -140,7 +152,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
140152

141153
if (file==NULL)
142154
return UNZ_PARAMERROR;
143-
@@ -851,21 +876,34 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
155+
@@ -907,21 +932,34 @@
144156
file_info_internal.offset_curfile = uL;
145157

146158
lSeek+=file_info.size_filename;
@@ -186,7 +198,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
186198
}
187199

188200
/* Read extrafield */
189-
@@ -951,6 +989,62 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
201+
@@ -1007,6 +1045,64 @@
190202
}
191203

192204
}
@@ -199,14 +211,16 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
199211
+ /* dataSize includes version (1 byte), uCrc (4 bytes), and
200212
+ * the filename data. If it's too small, fileNameSize below
201213
+ * would overflow. */
202-
+ err = UNZ_ERRNO;
203-
+ break;
214+
+ if (ZSEEK64(s->z_filefunc, s->filestream, dataSize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
215+
+ {
216+
+ err = UNZ_ERRNO;
217+
+ }
204218
+ }
205219
+ else if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK)
206220
+ {
207221
+ err = UNZ_ERRNO;
208222
+ }
209-
+ if (version != 1)
223+
+ else if (version != 1)
210224
+ {
211225
+ if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0)
212226
+ {
@@ -249,7 +263,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644
249263
else
250264
{
251265
if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
252-
@@ -1050,6 +1144,9 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
266+
@@ -1106,6 +1202,9 @@
253267
pfile_info->compressed_size = (uLong)file_info64.compressed_size;
254268
pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
255269

‎src/zlib_version.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/dep_updaters/update-zlib.sh
33
#ifndef SRC_ZLIB_VERSION_H_
44
#define SRC_ZLIB_VERSION_H_
5-
#define ZLIB_VERSION "1.4-ec453dc"
5+
#define ZLIB_VERSION "1.4-401d185"
66
#endif // SRC_ZLIB_VERSION_H_

0 commit comments

Comments
 (0)