From 7a2f608ca74cdb3d8704deafb89845c91f6a91f1 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 22 Nov 2026 00:35:05 +0000 Subject: [PATCH] deps: update zlib to 1.4-401d185 --- deps/zlib/contrib/minizip/unzip.c | 8 ++-- deps/zlib/contrib/tests/utils_unittest.cc | 38 +++++++++++++++++- .../test/data/short_unicode_path_extra.zip | Bin 0 -> 1391 bytes deps/zlib/google/test_data.filelist | 1 + ...nizip-parse-unicode-path-extra-field.patch | 30 ++++++++++---- src/zlib_version.h | 2 +- 6 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 deps/zlib/google/test/data/short_unicode_path_extra.zip diff --git a/deps/zlib/contrib/minizip/unzip.c b/deps/zlib/contrib/minizip/unzip.c index e45d0cf63650..c5e69721a8f7 100644 --- a/deps/zlib/contrib/minizip/unzip.c +++ b/deps/zlib/contrib/minizip/unzip.c @@ -1054,14 +1054,16 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, /* dataSize includes version (1 byte), uCrc (4 bytes), and * the filename data. If it's too small, fileNameSize below * would overflow. */ - err = UNZ_ERRNO; - break; + if (ZSEEK64(s->z_filefunc, s->filestream, dataSize, ZLIB_FILEFUNC_SEEK_CUR) != 0) + { + err = UNZ_ERRNO; + } } else if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK) { err = UNZ_ERRNO; } - if (version != 1) + else if (version != 1) { if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0) { diff --git a/deps/zlib/contrib/tests/utils_unittest.cc b/deps/zlib/contrib/tests/utils_unittest.cc index 148cc7c66558..a9a40a755b6d 100644 --- a/deps/zlib/contrib/tests/utils_unittest.cc +++ b/deps/zlib/contrib/tests/utils_unittest.cc @@ -1438,7 +1438,15 @@ TEST(ZlibTest, ZipUnicodePathExtraSizeFilenameOverflow) { base::FilePath zip_file = TestDataDir().AppendASCII("unicode_path_extra_overflow.zip"); unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str()); ASSERT_NE(uzf, nullptr); - EXPECT_EQ(unzGoToFirstFile(uzf), UNZ_ERRNO); + + char name[100]; + unz_file_info file_info; + ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK); + // The bad Unicode Path Extra Field should be ignored, and we get the regular + // filename. + ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr, + 0, nullptr, 0), UNZ_OK); + ASSERT_EQ(std::string(name), "\xc8\xfe \xc8\xfe\xc8\xfe.txt"); EXPECT_EQ(unzClose(uzf), UNZ_OK); } @@ -1482,6 +1490,34 @@ TEST(ZlibTest, ZipUnicodePathExtra) { EXPECT_EQ(unzClose(uzf), UNZ_OK); } +TEST(ZlibTest, ShortZipUnicodePathExtra) { + base::FilePath zip_file = TestDataDir().AppendASCII("short_unicode_path_extra.zip"); + unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str()); + ASSERT_NE(uzf, nullptr); + + char name[100]; + unz_file_info file_info; + + ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK); + ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr, + 0, nullptr, 0), UNZ_OK); + ASSERT_EQ(std::string(name), "receipt.txt"); + + // The "decoy.dat" entry has an invalid (too short) Unicode Path Extra Field. + // Ignore the extra field rather than erroring out. + ASSERT_EQ(unzGoToNextFile(uzf), UNZ_OK); + ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr, + 0, nullptr, 0), UNZ_OK); + ASSERT_EQ(std::string(name), "decoy.dat"); + + ASSERT_EQ(unzGoToNextFile(uzf), UNZ_OK); + ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name), nullptr, + 0, nullptr, 0), UNZ_OK); + ASSERT_EQ(std::string(name), "malware.exe"); + + EXPECT_EQ(unzClose(uzf), UNZ_OK); +} + TEST(ZlibTest, ZipEncryptionFlagMismatch) { // Test archive created with info-zip: // $ echo -n a > a && zip -P a -k a.zip a diff --git a/deps/zlib/google/test/data/short_unicode_path_extra.zip b/deps/zlib/google/test/data/short_unicode_path_extra.zip new file mode 100644 index 0000000000000000000000000000000000000000..f2ca0ffbb683c78ec930f189fc882837e98ace0e GIT binary patch literal 1391 zcmWIWW@Zs#0D}an*tK)E1j+$9Aj}QKMXAZDnFS?!B^4zh8Hst>3YGb#3TgR8Ai7AQ zptLACBe6JDk(Vm~#h9Y6jh>=F?I6qv#3`xC`IUMpi6wdYB^jA{=?W$J3dO0Z3K^+I zspxv=#jDL`U;%0ZVvrMZ6LZQFi&FJcD^h)9!gn1)jz!2tt$C8-r9AlpHX1i1@D zL){Hzfq?=8Ljr^~c*(uX;oSP lEHlvTL@%CT8W|XxflQ>rD!`i+Tuv}EFf*(LO05A~0{~mq<8uH2 literal 0 HcmV?d00001 diff --git a/deps/zlib/google/test_data.filelist b/deps/zlib/google/test_data.filelist index 9761df114797..0e59c5144a9e 100644 --- a/deps/zlib/google/test_data.filelist +++ b/deps/zlib/google/test_data.filelist @@ -23,6 +23,7 @@ test/data/enc_flag_mismatch.zip test/data/evil.zip test/data/evil_via_absolute_file_name.zip test/data/evil_via_invalid_utf8.zip +test/data/short_unicode_path_extra.zip test/data/symlink_absolute_path.zip test/data/symlink_duplicate_link.zip test/data/symlink_evil_relative_path.zip diff --git a/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch b/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch index 412cfd681bb4..2b2eb3375e52 100644 --- a/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch +++ b/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch @@ -90,6 +90,18 @@ Date: Mon Apr 27 13:24:27 2026 +0200 Change-Id: I06e6c8a8ff8baa729b10a67a998f8804803ae6cd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7797172 +commit 14964355aff9695897f7a2e06a4af2c4e25b71d5 +Author: Hans Wennborg +Date: Wed Sep 16 15:45:40 2026 +0200 + + [minizip] Ignore invalid Unicode Path Extra Fields rather than erroring + + To match what other extractors do. + + Bug: 553273868 + Change-Id: Ia5d64fb92d2abe5eba1e74f7180688a7a4362987 + Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8418328 + diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c index fb5eb0bf0f852..c15f4484f75f7 100644 --- a/third_party/zlib/contrib/minizip/unzip.c @@ -102,7 +114,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 #include #include #include -@@ -195,6 +196,26 @@ typedef struct +@@ -195,6 +196,26 @@ Reads a long in LSB order from the given gz_stream. Sets */ @@ -129,7 +141,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX) { -@@ -780,6 +801,10 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, +@@ -836,6 +857,10 @@ uLong uMagic; long lSeek=0; uLong uL; @@ -140,7 +152,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 if (file==NULL) return UNZ_PARAMERROR; -@@ -851,21 +876,34 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, +@@ -907,21 +932,34 @@ file_info_internal.offset_curfile = uL; lSeek+=file_info.size_filename; @@ -186,7 +198,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 } /* Read extrafield */ -@@ -951,6 +989,62 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, +@@ -1007,6 +1045,64 @@ } } @@ -199,14 +211,16 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 + /* dataSize includes version (1 byte), uCrc (4 bytes), and + * the filename data. If it's too small, fileNameSize below + * would overflow. */ -+ err = UNZ_ERRNO; -+ break; ++ if (ZSEEK64(s->z_filefunc, s->filestream, dataSize, ZLIB_FILEFUNC_SEEK_CUR) != 0) ++ { ++ err = UNZ_ERRNO; ++ } + } + else if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK) + { + err = UNZ_ERRNO; + } -+ if (version != 1) ++ else if (version != 1) + { + if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0) + { @@ -249,7 +263,7 @@ index fb5eb0bf0f852..c15f4484f75f7 100644 else { if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) -@@ -1050,6 +1144,9 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, +@@ -1106,6 +1202,9 @@ pfile_info->compressed_size = (uLong)file_info64.compressed_size; pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; diff --git a/src/zlib_version.h b/src/zlib_version.h index f99f6266691b..696df9f6dff0 100644 --- a/src/zlib_version.h +++ b/src/zlib_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-zlib.sh #ifndef SRC_ZLIB_VERSION_H_ #define SRC_ZLIB_VERSION_H_ -#define ZLIB_VERSION "1.4-ec453dc" +#define ZLIB_VERSION "1.4-401d185" #endif // SRC_ZLIB_VERSION_H_