Skip to content

Commit

Permalink
deps: update zlib to 1.3.0.1-motley-24342f6
Browse files Browse the repository at this point in the history
PR-URL: #52123
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
nodejs-github-bot authored and richardlau committed May 16, 2024
1 parent af3e320 commit 755399d
Show file tree
Hide file tree
Showing 31 changed files with 1,208 additions and 1,149 deletions.
5 changes: 0 additions & 5 deletions deps/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ source_set("zlib_slide_hash_simd") {
config("zlib_warnings") {
if (is_clang) {
cflags = [
"-Wno-deprecated-non-prototype",
"-Wno-incompatible-pointer-types",
"-Wunused-variable",
]
Expand Down Expand Up @@ -380,7 +379,6 @@ config("minizip_warnings") {
cflags = [
# zlib uses `if ((a == b))` for some reason.
"-Wno-parentheses-equality",
"-Wno-deprecated-non-prototype",
]
}
}
Expand Down Expand Up @@ -452,8 +450,6 @@ if (!is_win || target_os != "winuwp") {
if (is_clang) {
cflags = [
"-Wno-incompatible-pointer-types-discards-qualifiers",

"-Wno-deprecated-non-prototype",
]
}

Expand All @@ -476,7 +472,6 @@ if (!is_win || target_os != "winuwp") {
if (is_clang) {
cflags = [
"-Wno-incompatible-pointer-types-discards-qualifiers",
"-Wno-deprecated-non-prototype",
]
}

Expand Down
76 changes: 51 additions & 25 deletions deps/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,55 @@ option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF)
option(ENABLE_SIMD_AVX512 "Enable SIMD AXV512 optimizations" OFF)
option(USE_ZLIB_RABIN_KARP_HASH "Enable bitstream compatibility with canonical zlib" OFF)
option(BUILD_UNITTESTS "Enable standalone unit tests build" OFF)
option(BUILD_MINIZIP_BIN "Enable building minzip_bin tool" OFF)

if (USE_ZLIB_RABIN_KARP_HASH)
add_definitions(-DUSE_ZLIB_RABIN_KARP_ROLLING_HASH)
endif()

# TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx)
# and architectures (e.g. Arm).
# TODO(cavalcantii): add support for other OSes (e.g. Android, Fuchsia, etc)
# and architectures (e.g. RISCV).
if (ENABLE_SIMD_OPTIMIZATIONS)
add_definitions(-DINFLATE_CHUNK_SIMD_SSE2)
add_definitions(-DADLER32_SIMD_SSSE3)
add_definitions(-DINFLATE_CHUNK_READ_64LE)
add_definitions(-DCRC32_SIMD_SSE42_PCLMUL)
if (ENABLE_SIMD_AVX512)
add_definitions(-DCRC32_SIMD_AVX512_PCLMUL)
add_compile_options(-mvpclmulqdq -msse2 -mavx512f -mpclmul)
else()
add_compile_options(-msse4.2 -mpclmul)
endif()
add_definitions(-DDEFLATE_SLIDE_HASH_SSE2)
# Required by CPU features detection code.
add_definitions(-DX86_NOT_WINDOWS)
# Apparently some environments (e.g. CentOS) require to explicitly link
# with pthread and that is required by the CPU features detection code.
find_package (Threads REQUIRED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# Apparently some environments (e.g. CentOS) require to explicitly link
# with pthread and that is required by the CPU features detection code.
find_package (Threads REQUIRED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
add_definitions(-DINFLATE_CHUNK_SIMD_SSE2)
add_definitions(-DADLER32_SIMD_SSSE3)
add_definitions(-DINFLATE_CHUNK_READ_64LE)
add_definitions(-DCRC32_SIMD_SSE42_PCLMUL)
if (ENABLE_SIMD_AVX512)
add_definitions(-DCRC32_SIMD_AVX512_PCLMUL)
add_compile_options(-mvpclmulqdq -msse2 -mavx512f -mpclmul)
else()
add_compile_options(-msse4.2 -mpclmul)
endif()
add_definitions(-DDEFLATE_SLIDE_HASH_SSE2)
# Required by CPU features detection code.
add_definitions(-DX86_NOT_WINDOWS)
endif()

if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") OR
(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
add_definitions(-DINFLATE_CHUNK_SIMD_NEON)
add_definitions(-DADLER32_SIMD_NEON)
add_definitions(-DINFLATE_CHUNK_READ_64LE)
add_definitions(-DCRC32_ARMV8_CRC32)
add_definitions(-DDEFLATE_SLIDE_HASH_NEON)
# Required by CPU features detection code.
if (APPLE)
add_definitions(-DARMV8_OS_MACOS)
endif()

if (UNIX AND NOT APPLE)
add_definitions(-DARMV8_OS_LINUX)
endif()

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+crc+crypto")
endif()
endif()

#
Expand Down Expand Up @@ -300,8 +323,11 @@ endif()
#============================================================================
# Minigzip tool
#============================================================================
add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c
contrib/minizip/ioapi.h contrib/minizip/unzip.c
contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h
)
target_link_libraries(minizip_bin zlib)
# TODO(cavalcantii): get it working on Windows.
if (BUILD_MINIZIP_BIN)
add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c
contrib/minizip/ioapi.h contrib/minizip/unzip.c
contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h
)
target_link_libraries(minizip_bin zlib)
endif()
3 changes: 3 additions & 0 deletions deps/zlib/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
monorail: {
component: "Internals"
}
buganizer_public: {
component_id: 1456292
}
12 changes: 8 additions & 4 deletions deps/zlib/contrib/minizip/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=cc
CFLAGS=-O -I../..
CFLAGS := $(CFLAGS) -O -I../..

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

test: miniunz minizip
./minizip test readme.txt
@rm -f test.*
@echo hello hello hello > test.txt
./minizip test test.txt
./miniunz -l test.zip
mv readme.txt readme.old
@mv test.txt test.old
./miniunz test.zip
@cmp test.txt test.old
@rm -f test.*

clean:
/bin/rm -f *.o *~ minizip miniunz
/bin/rm -f *.o *~ minizip miniunz test.*
15 changes: 11 additions & 4 deletions deps/zlib/contrib/minizip/README.chromium
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Name: ZIP file API for reading file entries in a ZIP archive
Short Name: minizip
URL: https://github.com/madler/zlib/tree/master/contrib/minizip
Version: 1.2.12
Version: 1.3.0.1
License: Zlib
License File: //third_party/zlib/LICENSE
Security Critical: yes
Expand All @@ -13,9 +13,16 @@ 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)

- Check for overly long filename, comment, or extra field in
zipOpenNewFileInZip4_64 (crbug.com/1470539).
0016-minizip-parse-unicode-path-extra-field.patch
29 changes: 13 additions & 16 deletions deps/zlib/contrib/minizip/crypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
{
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */

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

/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
{
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
Expand All @@ -62,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
{
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
Expand All @@ -77,24 +75,23 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))

#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))

#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED

#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif

static int crypthead(const char* passwd, /* password string */
unsigned char* buf, /* where to write header */
int bufSize,
unsigned long* pkeys,
const z_crc_t* pcrc_32_tab,
unsigned long crcForCrypting)
{
int n; /* index in random header */
static unsigned crypthead(const char* passwd, /* password string */
unsigned char* buf, /* where to write header */
int bufSize,
unsigned long* pkeys,
const z_crc_t* pcrc_32_tab,
unsigned long crcForCrypting) {
unsigned n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
Expand Down
Loading

0 comments on commit 755399d

Please sign in to comment.