Skip to content

Commit 70a0510

Browse files
deps: update zlib to 1.3.0.1-motley-24342f6
PR-URL: #52123 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 8206f6b commit 70a0510

32 files changed

+1209
-1150
lines changed

deps/zlib/BUILD.gn

-5
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ source_set("zlib_slide_hash_simd") {
274274
config("zlib_warnings") {
275275
if (is_clang) {
276276
cflags = [
277-
"-Wno-deprecated-non-prototype",
278277
"-Wno-incompatible-pointer-types",
279278
"-Wunused-variable",
280279
]
@@ -380,7 +379,6 @@ config("minizip_warnings") {
380379
cflags = [
381380
# zlib uses `if ((a == b))` for some reason.
382381
"-Wno-parentheses-equality",
383-
"-Wno-deprecated-non-prototype",
384382
]
385383
}
386384
}
@@ -452,8 +450,6 @@ if (!is_win || target_os != "winuwp") {
452450
if (is_clang) {
453451
cflags = [
454452
"-Wno-incompatible-pointer-types-discards-qualifiers",
455-
456-
"-Wno-deprecated-non-prototype",
457453
]
458454
}
459455

@@ -476,7 +472,6 @@ if (!is_win || target_os != "winuwp") {
476472
if (is_clang) {
477473
cflags = [
478474
"-Wno-incompatible-pointer-types-discards-qualifiers",
479-
"-Wno-deprecated-non-prototype",
480475
]
481476
}
482477

deps/zlib/CMakeLists.txt

+51-25
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,55 @@ option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF)
2525
option(ENABLE_SIMD_AVX512 "Enable SIMD AXV512 optimizations" OFF)
2626
option(USE_ZLIB_RABIN_KARP_HASH "Enable bitstream compatibility with canonical zlib" OFF)
2727
option(BUILD_UNITTESTS "Enable standalone unit tests build" OFF)
28+
option(BUILD_MINIZIP_BIN "Enable building minzip_bin tool" OFF)
2829

2930
if (USE_ZLIB_RABIN_KARP_HASH)
3031
add_definitions(-DUSE_ZLIB_RABIN_KARP_ROLLING_HASH)
3132
endif()
3233

33-
# TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx)
34-
# and architectures (e.g. Arm).
34+
# TODO(cavalcantii): add support for other OSes (e.g. Android, Fuchsia, etc)
35+
# and architectures (e.g. RISCV).
3536
if (ENABLE_SIMD_OPTIMIZATIONS)
36-
add_definitions(-DINFLATE_CHUNK_SIMD_SSE2)
37-
add_definitions(-DADLER32_SIMD_SSSE3)
38-
add_definitions(-DINFLATE_CHUNK_READ_64LE)
39-
add_definitions(-DCRC32_SIMD_SSE42_PCLMUL)
40-
if (ENABLE_SIMD_AVX512)
41-
add_definitions(-DCRC32_SIMD_AVX512_PCLMUL)
42-
add_compile_options(-mvpclmulqdq -msse2 -mavx512f -mpclmul)
43-
else()
44-
add_compile_options(-msse4.2 -mpclmul)
45-
endif()
46-
add_definitions(-DDEFLATE_SLIDE_HASH_SSE2)
47-
# Required by CPU features detection code.
48-
add_definitions(-DX86_NOT_WINDOWS)
49-
# Apparently some environments (e.g. CentOS) require to explicitly link
50-
# with pthread and that is required by the CPU features detection code.
51-
find_package (Threads REQUIRED)
52-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
53-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
37+
# Apparently some environments (e.g. CentOS) require to explicitly link
38+
# with pthread and that is required by the CPU features detection code.
39+
find_package (Threads REQUIRED)
40+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
41+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
42+
43+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
44+
add_definitions(-DINFLATE_CHUNK_SIMD_SSE2)
45+
add_definitions(-DADLER32_SIMD_SSSE3)
46+
add_definitions(-DINFLATE_CHUNK_READ_64LE)
47+
add_definitions(-DCRC32_SIMD_SSE42_PCLMUL)
48+
if (ENABLE_SIMD_AVX512)
49+
add_definitions(-DCRC32_SIMD_AVX512_PCLMUL)
50+
add_compile_options(-mvpclmulqdq -msse2 -mavx512f -mpclmul)
51+
else()
52+
add_compile_options(-msse4.2 -mpclmul)
53+
endif()
54+
add_definitions(-DDEFLATE_SLIDE_HASH_SSE2)
55+
# Required by CPU features detection code.
56+
add_definitions(-DX86_NOT_WINDOWS)
57+
endif()
58+
59+
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") OR
60+
(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
61+
add_definitions(-DINFLATE_CHUNK_SIMD_NEON)
62+
add_definitions(-DADLER32_SIMD_NEON)
63+
add_definitions(-DINFLATE_CHUNK_READ_64LE)
64+
add_definitions(-DCRC32_ARMV8_CRC32)
65+
add_definitions(-DDEFLATE_SLIDE_HASH_NEON)
66+
# Required by CPU features detection code.
67+
if (APPLE)
68+
add_definitions(-DARMV8_OS_MACOS)
69+
endif()
70+
71+
if (UNIX AND NOT APPLE)
72+
add_definitions(-DARMV8_OS_LINUX)
73+
endif()
74+
75+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+crc+crypto")
76+
endif()
5477
endif()
5578

5679
#
@@ -300,8 +323,11 @@ endif()
300323
#============================================================================
301324
# Minigzip tool
302325
#============================================================================
303-
add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c
304-
contrib/minizip/ioapi.h contrib/minizip/unzip.c
305-
contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h
306-
)
307-
target_link_libraries(minizip_bin zlib)
326+
# TODO(cavalcantii): get it working on Windows.
327+
if (BUILD_MINIZIP_BIN)
328+
add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c
329+
contrib/minizip/ioapi.h contrib/minizip/unzip.c
330+
contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h
331+
)
332+
target_link_libraries(minizip_bin zlib)
333+
endif()

deps/zlib/DIR_METADATA

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
monorail: {
22
component: "Internals"
33
}
4+
buganizer_public: {
5+
component_id: 1456292
6+
}

deps/zlib/contrib/minizip/Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CC=cc
2-
CFLAGS=-O -I../..
2+
CFLAGS := $(CFLAGS) -O -I../..
33

44
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
55
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
@@ -16,10 +16,14 @@ minizip: $(ZIP_OBJS)
1616
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
1717

1818
test: miniunz minizip
19-
./minizip test readme.txt
19+
@rm -f test.*
20+
@echo hello hello hello > test.txt
21+
./minizip test test.txt
2022
./miniunz -l test.zip
21-
mv readme.txt readme.old
23+
@mv test.txt test.old
2224
./miniunz test.zip
25+
@cmp test.txt test.old
26+
@rm -f test.*
2327

2428
clean:
25-
/bin/rm -f *.o *~ minizip miniunz
29+
/bin/rm -f *.o *~ minizip miniunz test.*
+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Name: ZIP file API for reading file entries in a ZIP archive
22
Short Name: minizip
33
URL: https://github.com/madler/zlib/tree/master/contrib/minizip
4-
Version: 1.2.12
4+
Version: 1.3.0.1
55
License: Zlib
66
License File: //third_party/zlib/LICENSE
77
Security Critical: yes
@@ -13,9 +13,16 @@ Minizip provides API on top of zlib that can enumerate and extract ZIP archive
1313
files. See minizip.md for chromium build instructions.
1414

1515
Local Modifications:
16+
- Fixed uncompressing files with wrong uncompressed size set
17+
crrev.com/268940
18+
0014-minizip-unzip-with-incorrect-size.patch
19+
20+
- Enable traditional PKWARE decryption in zlib/contrib/minizip
21+
Correct the value of rest_read_compressed when decompressing an encrypted
22+
zip. (crrev.com/580862)
23+
0015-minizip-unzip-enable-decryption.patch
24+
1625
- Add parsing of the 'Info-ZIP Unicode Path Extra Field' as described in
1726
https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT section 4.6.9.
1827
(see crrev.com/1002476)
19-
20-
- Check for overly long filename, comment, or extra field in
21-
zipOpenNewFileInZip4_64 (crbug.com/1470539).
28+
0016-minizip-parse-unicode-path-extra-field.patch

deps/zlib/contrib/minizip/crypt.h

+13-16
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@
3232
/***********************************************************************
3333
* Return the next byte in the pseudo-random sequence
3434
*/
35-
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
36-
{
35+
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
3736
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
3837
* unpredictable manner on 16-bit systems; not a problem
3938
* with any known compiler so far, though */
4039

40+
(void)pcrc_32_tab;
4141
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
4242
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
4343
}
4444

4545
/***********************************************************************
4646
* Update the encryption keys with the next byte of plain text
4747
*/
48-
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
49-
{
48+
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
5049
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
5150
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
5251
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
@@ -62,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
6261
* Initialize the encryption keys and the random header according to
6362
* the given password.
6463
*/
65-
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
66-
{
64+
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
6765
*(pkeys+0) = 305419896L;
6866
*(pkeys+1) = 591751049L;
6967
*(pkeys+2) = 878082192L;
@@ -77,24 +75,23 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
7775
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
7876

7977
#define zencode(pkeys,pcrc_32_tab,c,t) \
80-
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
78+
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
8179

8280
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
8381

8482
#define RAND_HEAD_LEN 12
8583
/* "last resort" source for second part of crypt seed pattern */
8684
# ifndef ZCR_SEED2
87-
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
85+
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
8886
# endif
8987

90-
static int crypthead(const char* passwd, /* password string */
91-
unsigned char* buf, /* where to write header */
92-
int bufSize,
93-
unsigned long* pkeys,
94-
const z_crc_t* pcrc_32_tab,
95-
unsigned long crcForCrypting)
96-
{
97-
int n; /* index in random header */
88+
static unsigned crypthead(const char* passwd, /* password string */
89+
unsigned char* buf, /* where to write header */
90+
int bufSize,
91+
unsigned long* pkeys,
92+
const z_crc_t* pcrc_32_tab,
93+
unsigned long crcForCrypting) {
94+
unsigned n; /* index in random header */
9895
int t; /* temporary */
9996
int c; /* random byte */
10097
unsigned char header[RAND_HEAD_LEN-2]; /* random header */

0 commit comments

Comments
 (0)