Skip to content

Commit 3f78ca2

Browse files
deps: update zlib to 1.3.2.1-motley-8b3aa8a
1 parent b59def5 commit 3f78ca2

7 files changed

Lines changed: 73 additions & 1 deletion

File tree

deps/zlib/contrib/minizip/unzip.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
14391439
*/
14401440
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
14411441
err=UNZ_ERRNO;
1442+
else if ((err==UNZ_OK) && ((uFlags & 1) != (s->cur_file_info.flag & 1)))
1443+
err=UNZ_BADZIPFILE; /* LFH/CD encryption flag mismatch */
14421444

14431445
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
14441446
err=UNZ_ERRNO;

deps/zlib/contrib/tests/utils_unittest.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,29 @@ TEST(ZlibTest, ZipUnicodePathExtra) {
14241424
EXPECT_EQ(unzClose(uzf), UNZ_OK);
14251425
}
14261426

1427+
TEST(ZlibTest, ZipEncryptionFlagMismatch) {
1428+
// Test archive created with info-zip:
1429+
// $ echo -n a > a && zip -P a -k a.zip a
1430+
// and then hex-edited to drop the encrypted flag from the central directory.
1431+
base::FilePath zip_file = TestDataDir().AppendASCII("enc_flag_mismatch.zip");
1432+
1433+
unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
1434+
ASSERT_NE(uzf, nullptr);
1435+
1436+
char name[100];
1437+
unz_file_info file_info;
1438+
1439+
ASSERT_EQ(unzGoToFirstFile(uzf), UNZ_OK);
1440+
ASSERT_EQ(unzGetCurrentFileInfo(uzf, &file_info, name, sizeof(name),
1441+
nullptr, 0, nullptr, 0), UNZ_OK);
1442+
ASSERT_EQ(std::string(name), "A");
1443+
1444+
// minizip should reject the member due to lfh/cd encrypted flag mismatch.
1445+
EXPECT_EQ(unzOpenCurrentFilePassword(uzf, "a"), UNZ_BADZIPFILE);
1446+
1447+
EXPECT_EQ(unzClose(uzf), UNZ_OK);
1448+
}
1449+
14271450
TEST(ZlibTest, Crbug500521311) {
14281451
base::FilePath zip_file = TestDataDir().AppendASCII("bug500521311.zip");
14291452
unzFile uzf = unzOpen(zip_file.AsUTF8Unsafe().c_str());
182 Bytes
Binary file not shown.

deps/zlib/google/test_data.filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ test/data/bug500521311.zip
1919
test/data/create_symlink_test_zips.py
2020
test/data/create_test_zip.sh
2121
test/data/empty.zip
22+
test/data/enc_flag_mismatch.zip
2223
test/data/evil.zip
2324
test/data/evil_via_absolute_file_name.zip
2425
test/data/evil_via_invalid_utf8.zip

deps/zlib/google/zip_reader_unittest.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,24 @@ TEST_F(ZipReaderTest, EncryptedFile_RightPassword) {
558558
EXPECT_TRUE(reader.ok());
559559
}
560560

561+
// An entry whose local file header has the "encrypted" general-purpose flag
562+
// bit set while the central directory does not should be rejected.
563+
TEST_F(ZipReaderTest, MismatchedEncryptionFlag) {
564+
ZipReader reader;
565+
ASSERT_TRUE(reader.Open(data_dir_.AppendASCII("enc_flag_mismatch.zip")));
566+
567+
const ZipReader::Entry* entry = reader.Next();
568+
ASSERT_TRUE(entry);
569+
EXPECT_EQ(base::FilePath::FromASCII("A"), entry->path);
570+
EXPECT_FALSE(entry->is_directory);
571+
std::string contents = "dummy";
572+
EXPECT_FALSE(reader.ExtractCurrentEntryToString(&contents));
573+
EXPECT_EQ("", contents);
574+
575+
EXPECT_FALSE(reader.Next());
576+
EXPECT_TRUE(reader.ok());
577+
}
578+
561579
// Verifies that the ZipReader class can extract a file from a zip archive
562580
// stored in memory. This test opens a zip archive in a std::string object,
563581
// extracts its content, and verifies the content is the same as the expected

deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,31 @@ index 82275d6c1775d..c8a01b23efd42 100644
2626
s->encrypted=1;
2727
}
2828
# endif
29+
30+
commit 874ed6b46a4f75407829e510db77cc673a4c86e7
31+
Author: Hans Wennborg <hans@chromium.org>
32+
Date: Mon Jun 15 11:33:46 2026 +0200
33+
34+
Check LFH / CD encryption flag consistency
35+
36+
unz64local_CheckCurrentFileCoherencyHeader performs various consistency
37+
checks on the values in the Local File Header and Central Directory.
38+
Make it check the encryption flag as well.
39+
40+
Bug: 514461031
41+
Change-Id: Ifaf8620c6e0c345118712bce6e1206bbb83b3a2d
42+
Reviewed-on: https://chromium-review.googlesource.com/7942389
43+
44+
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
45+
index 0264f7ac570f7..4eb0de302cfdf 100644
46+
--- a/third_party/zlib/contrib/minizip/unzip.c
47+
+++ b/third_party/zlib/contrib/minizip/unzip.c
48+
@@ -1439,6 +1439,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
49+
*/
50+
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
51+
err=UNZ_ERRNO;
52+
+ else if ((err==UNZ_OK) && ((uFlags & 1) != (s->cur_file_info.flag & 1)))
53+
+ err=UNZ_BADZIPFILE; /* LFH/CD encryption flag mismatch */
54+
55+
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
56+
err=UNZ_ERRNO;

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.3.2.1-motley-3246f1b"
5+
#define ZLIB_VERSION "1.3.2.1-motley-8b3aa8a"
66
#endif // SRC_ZLIB_VERSION_H_

0 commit comments

Comments
 (0)