Skip to content

Commit 755399d

Browse files
nodejs-github-botrichardlau
authored andcommittedMay 16, 2024
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 af3e320 commit 755399d

31 files changed

+1208
-1149
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 */

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

+31-47
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define _CRT_SECURE_NO_WARNINGS
1515
#endif
1616

17-
#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64)
17+
#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
1818
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
1919
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
2020
#define FTELLO_FUNC(stream) ftello(stream)
@@ -28,8 +28,7 @@
2828

2929
#include "ioapi.h"
3030

31-
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
32-
{
31+
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
3332
if (pfilefunc->zfile_func64.zopen64_file != NULL)
3433
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
3534
else
@@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
3837
}
3938
}
4039

41-
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
42-
{
40+
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
4341
if (pfilefunc->zfile_func64.zseek64_file != NULL)
4442
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
4543
else
@@ -52,25 +50,22 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
5250
}
5351
}
5452

55-
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
56-
{
53+
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
5754
if (pfilefunc->zfile_func64.zseek64_file != NULL)
5855
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
5956
else
6057
{
61-
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
58+
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
6259
if ((tell_uLong) == MAXU32)
6360
return (ZPOS64_T)-1;
6461
else
6562
return tell_uLong;
6663
}
6764
}
6865

69-
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
70-
{
66+
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
7167
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
7268
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
73-
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
7469
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
7570
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
7671
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
@@ -84,18 +79,10 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
8479

8580

8681

87-
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
88-
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
89-
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
90-
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
91-
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
92-
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
93-
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
94-
95-
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
96-
{
82+
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
9783
FILE* file = NULL;
9884
const char* mode_fopen = NULL;
85+
(void)opaque;
9986
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
10087
mode_fopen = "rb";
10188
else
@@ -110,10 +97,10 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
11097
return file;
11198
}
11299

113-
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
114-
{
100+
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
115101
FILE* file = NULL;
116102
const char* mode_fopen = NULL;
103+
(void)opaque;
117104
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
118105
mode_fopen = "rb";
119106
else
@@ -129,39 +116,39 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
129116
}
130117

131118

132-
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
133-
{
119+
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
134120
uLong ret;
121+
(void)opaque;
135122
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
136123
return ret;
137124
}
138125

139-
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
140-
{
126+
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
141127
uLong ret;
128+
(void)opaque;
142129
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
143130
return ret;
144131
}
145132

146-
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
147-
{
133+
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
148134
long ret;
135+
(void)opaque;
149136
ret = ftell((FILE *)stream);
150137
return ret;
151138
}
152139

153140

154-
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
155-
{
141+
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
156142
ZPOS64_T ret;
157-
ret = FTELLO_FUNC((FILE *)stream);
143+
(void)opaque;
144+
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
158145
return ret;
159146
}
160147

161-
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
162-
{
148+
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
163149
int fseek_origin=0;
164150
long ret;
151+
(void)opaque;
165152
switch (origin)
166153
{
167154
case ZLIB_FILEFUNC_SEEK_CUR :
@@ -176,15 +163,15 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
176163
default: return -1;
177164
}
178165
ret = 0;
179-
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
166+
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
180167
ret = -1;
181168
return ret;
182169
}
183170

184-
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
185-
{
171+
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
186172
int fseek_origin=0;
187173
long ret;
174+
(void)opaque;
188175
switch (origin)
189176
{
190177
case ZLIB_FILEFUNC_SEEK_CUR :
@@ -200,30 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
200187
}
201188
ret = 0;
202189

203-
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
190+
if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
204191
ret = -1;
205192

206193
return ret;
207194
}
208195

209196

210-
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
211-
{
197+
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
212198
int ret;
199+
(void)opaque;
213200
ret = fclose((FILE *)stream);
214201
return ret;
215202
}
216203

217-
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
218-
{
204+
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
219205
int ret;
206+
(void)opaque;
220207
ret = ferror((FILE *)stream);
221208
return ret;
222209
}
223210

224-
void fill_fopen_filefunc (pzlib_filefunc_def)
225-
zlib_filefunc_def* pzlib_filefunc_def;
226-
{
211+
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
227212
pzlib_filefunc_def->zopen_file = fopen_file_func;
228213
pzlib_filefunc_def->zread_file = fread_file_func;
229214
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
@@ -234,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
234219
pzlib_filefunc_def->opaque = NULL;
235220
}
236221

237-
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
238-
{
222+
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
239223
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
240224
pzlib_filefunc_def->zread_file = fread_file_func;
241225
pzlib_filefunc_def->zwrite_file = fwrite_file_func;

‎deps/zlib/contrib/minizip/ioapi.h

+24-22
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#define ftello64 ftell
5151
#define fseeko64 fseek
5252
#else
53-
#ifdef __FreeBSD__
53+
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
5454
#define fopen64 fopen
5555
#define ftello64 ftello
5656
#define fseeko64 fseeko
@@ -82,7 +82,7 @@
8282
#include "mz64conf.h"
8383
#endif
8484

85-
/* a type choosen by DEFINE */
85+
/* a type chosen by DEFINE */
8686
#ifdef HAVE_64BIT_INT_CUSTOM
8787
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
8888
#else
@@ -91,8 +91,7 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
9191
typedef uint64_t ZPOS64_T;
9292
#else
9393

94-
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
95-
#define MAXU32 0xffffffff
94+
9695

9796
#if defined(_MSC_VER) || defined(__BORLANDC__)
9897
typedef unsigned __int64 ZPOS64_T;
@@ -102,7 +101,10 @@ typedef unsigned long long int ZPOS64_T;
102101
#endif
103102
#endif
104103

105-
104+
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
105+
#ifndef MAXU32
106+
#define MAXU32 (0xffffffff)
107+
#endif
106108

107109
#ifdef __cplusplus
108110
extern "C" {
@@ -132,17 +134,17 @@ extern "C" {
132134

133135

134136

135-
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
136-
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
137-
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
138-
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
139-
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
137+
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
138+
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
139+
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
140+
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
141+
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
140142

141-
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
142-
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
143+
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
144+
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
143145

144146

145-
/* here is the "old" 32 bits structure structure */
147+
/* here is the "old" 32 bits structure */
146148
typedef struct zlib_filefunc_def_s
147149
{
148150
open_file_func zopen_file;
@@ -155,9 +157,9 @@ typedef struct zlib_filefunc_def_s
155157
voidpf opaque;
156158
} zlib_filefunc_def;
157159

158-
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
159-
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
160-
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
160+
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
161+
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
162+
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
161163

162164
typedef struct zlib_filefunc64_def_s
163165
{
@@ -171,8 +173,8 @@ typedef struct zlib_filefunc64_def_s
171173
voidpf opaque;
172174
} zlib_filefunc64_def;
173175

174-
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
175-
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
176+
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
177+
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
176178

177179
/* now internal definition, only for zip.c and unzip.h */
178180
typedef struct zlib_filefunc64_32_def_s
@@ -191,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s
191193
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
192194
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
193195

194-
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
195-
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
196-
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
196+
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
197+
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
198+
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
197199

198-
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
200+
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
199201

200202
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
201203
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))

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

+19-47
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
2626
#endif
2727

28-
2928
#ifdef _WIN32_WINNT
3029
#undef _WIN32_WINNT
3130
#define _WIN32_WINNT 0x601
@@ -38,14 +37,6 @@
3837
#endif
3938
#endif
4039

41-
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
42-
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
43-
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
44-
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
45-
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
46-
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
47-
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
48-
4940
typedef struct
5041
{
5142
HANDLE hf;
@@ -57,8 +48,7 @@ static void win32_translate_open_mode(int mode,
5748
DWORD* lpdwDesiredAccess,
5849
DWORD* lpdwCreationDisposition,
5950
DWORD* lpdwShareMode,
60-
DWORD* lpdwFlagsAndAttributes)
61-
{
51+
DWORD* lpdwFlagsAndAttributes) {
6252
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
6353

6454
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
@@ -79,8 +69,7 @@ static void win32_translate_open_mode(int mode,
7969
}
8070
}
8171

82-
static voidpf win32_build_iowin(HANDLE hFile)
83-
{
72+
static voidpf win32_build_iowin(HANDLE hFile) {
8473
voidpf ret=NULL;
8574

8675
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
@@ -98,8 +87,7 @@ static voidpf win32_build_iowin(HANDLE hFile)
9887
return ret;
9988
}
10089

101-
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
102-
{
90+
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
10391
const char* mode_fopen = NULL;
10492
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
10593
HANDLE hFile = NULL;
@@ -127,8 +115,7 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int
127115
}
128116

129117

130-
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
131-
{
118+
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
132119
const char* mode_fopen = NULL;
133120
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
134121
HANDLE hFile = NULL;
@@ -151,8 +138,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int
151138
}
152139

153140

154-
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
155-
{
141+
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
156142
const char* mode_fopen = NULL;
157143
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
158144
HANDLE hFile = NULL;
@@ -171,8 +157,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int
171157
}
172158

173159

174-
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
175-
{
160+
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
176161
const char* mode_fopen = NULL;
177162
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
178163
HANDLE hFile = NULL;
@@ -200,8 +185,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo
200185
}
201186

202187

203-
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
204-
{
188+
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
205189
uLong ret=0;
206190
HANDLE hFile = NULL;
207191
if (stream!=NULL)
@@ -222,8 +206,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL
222206
}
223207

224208

225-
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
226-
{
209+
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
227210
uLong ret=0;
228211
HANDLE hFile = NULL;
229212
if (stream!=NULL)
@@ -243,8 +226,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b
243226
return ret;
244227
}
245228

246-
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
247-
{
229+
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) {
248230
#ifdef IOWIN32_USING_WINRT_API
249231
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
250232
#else
@@ -263,8 +245,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
263245
#endif
264246
}
265247

266-
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
267-
{
248+
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
268249
long ret=-1;
269250
HANDLE hFile = NULL;
270251
if (stream!=NULL)
@@ -286,8 +267,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
286267
return ret;
287268
}
288269

289-
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
290-
{
270+
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
291271
ZPOS64_T ret= (ZPOS64_T)-1;
292272
HANDLE hFile = NULL;
293273
if (stream!=NULL)
@@ -311,8 +291,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
311291
}
312292

313293

314-
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
315-
{
294+
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
316295
DWORD dwMoveMethod=0xFFFFFFFF;
317296
HANDLE hFile = NULL;
318297

@@ -349,8 +328,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
349328
return ret;
350329
}
351330

352-
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
353-
{
331+
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
354332
DWORD dwMoveMethod=0xFFFFFFFF;
355333
HANDLE hFile = NULL;
356334
long ret=-1;
@@ -388,8 +366,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off
388366
return ret;
389367
}
390368

391-
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
392-
{
369+
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
393370
int ret=-1;
394371

395372
if (stream!=NULL)
@@ -406,8 +383,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
406383
return ret;
407384
}
408385

409-
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
410-
{
386+
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
411387
int ret=-1;
412388
if (stream!=NULL)
413389
{
@@ -416,8 +392,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
416392
return ret;
417393
}
418394

419-
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
420-
{
395+
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
421396
pzlib_filefunc_def->zopen_file = win32_open_file_func;
422397
pzlib_filefunc_def->zread_file = win32_read_file_func;
423398
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -428,8 +403,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
428403
pzlib_filefunc_def->opaque = NULL;
429404
}
430405

431-
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
432-
{
406+
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
433407
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
434408
pzlib_filefunc_def->zread_file = win32_read_file_func;
435409
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -441,8 +415,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
441415
}
442416

443417

444-
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
445-
{
418+
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
446419
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
447420
pzlib_filefunc_def->zread_file = win32_read_file_func;
448421
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -454,8 +427,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
454427
}
455428

456429

457-
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
458-
{
430+
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) {
459431
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
460432
pzlib_filefunc_def->zread_file = win32_read_file_func;
461433
pzlib_filefunc_def->zwrite_file = win32_write_file_func;

‎deps/zlib/contrib/minizip/iowin32.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
extern "C" {
1919
#endif
2020

21-
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
22-
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
23-
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
24-
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
21+
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
22+
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def);
23+
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def);
24+
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def);
2525

2626
#ifdef __cplusplus
2727
}

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

+28-56
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#endif
2828
#endif
2929

30-
#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
30+
#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || defined(__Fuchsia__) || defined(__ANDROID_API__)
3131
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
3232
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
3333
#define FTELLO_FUNC(stream) ftello(stream)
@@ -81,11 +81,7 @@
8181
filename : the filename of the file where date/time must be modified
8282
dosdate : the new date at the MSDos format (4 bytes)
8383
tmu_date : the SAME new date at the tm_unz format */
84-
void change_file_date(filename,dosdate,tmu_date)
85-
const char *filename;
86-
uLong dosdate;
87-
tm_unz tmu_date;
88-
{
84+
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
8985
#ifdef _WIN32
9086
HANDLE hFile;
9187
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
@@ -99,6 +95,7 @@ void change_file_date(filename,dosdate,tmu_date)
9995
CloseHandle(hFile);
10096
#else
10197
#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
98+
(void)dosdate;
10299
struct utimbuf ut;
103100
struct tm newdate;
104101
newdate.tm_sec = tmu_date.tm_sec;
@@ -114,6 +111,10 @@ void change_file_date(filename,dosdate,tmu_date)
114111

115112
ut.actime=ut.modtime=mktime(&newdate);
116113
utime(filename,&ut);
114+
#else
115+
(void)filename;
116+
(void)dosdate;
117+
(void)tmu_date;
117118
#endif
118119
#endif
119120
}
@@ -122,26 +123,24 @@ void change_file_date(filename,dosdate,tmu_date)
122123
/* mymkdir and change_file_date are not 100 % portable
123124
As I don't know well Unix, I wait feedback for the unix portion */
124125

125-
int mymkdir(dirname)
126-
const char* dirname;
127-
{
126+
static int mymkdir(const char* dirname) {
128127
int ret=0;
129128
#if defined(_WIN32)
130129
ret = _mkdir(dirname);
131130
#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
132131
ret = mkdir (dirname,0775);
132+
#else
133+
(void)dirname;
133134
#endif
134135
return ret;
135136
}
136137

137-
int makedir (newdir)
138-
char *newdir;
139-
{
138+
static int makedir(const char *newdir) {
140139
char *buffer ;
141140
char *p;
142-
int len = (int)strlen(newdir);
141+
size_t len = strlen(newdir);
143142

144-
if (len <= 0)
143+
if (len == 0)
145144
return 0;
146145

147146
buffer = (char*)malloc(len+1);
@@ -184,26 +183,23 @@ int makedir (newdir)
184183
return 1;
185184
}
186185

187-
void do_banner()
188-
{
189-
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
186+
static void do_banner(void) {
187+
printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
190188
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
191189
}
192190

193-
void do_help()
194-
{
191+
static void do_help(void) {
195192
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
196193
" -e Extract without pathname (junk paths)\n" \
197194
" -x Extract with pathname\n" \
198195
" -v list files\n" \
199196
" -l list files\n" \
200197
" -d directory to extract into\n" \
201198
" -o overwrite files without prompting\n" \
202-
" -p extract crypted file using password\n\n");
199+
" -p extract encrypted file using password\n\n");
203200
}
204201

205-
void Display64BitsSize(ZPOS64_T n, int size_char)
206-
{
202+
static void Display64BitsSize(ZPOS64_T n, int size_char) {
207203
/* to avoid compatibility problem , we do here the conversion */
208204
char number[21];
209205
int offset=19;
@@ -230,9 +226,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
230226
printf("%s",&number[pos_string]);
231227
}
232228

233-
int do_list(uf)
234-
unzFile uf;
235-
{
229+
static int do_list(unzFile uf) {
236230
uLong i;
237231
unz_global_info64 gi;
238232
int err;
@@ -247,7 +241,7 @@ int do_list(uf)
247241
char filename_inzip[256];
248242
unz_file_info64 file_info;
249243
uLong ratio=0;
250-
const char *string_method;
244+
const char *string_method = "";
251245
char charCrypt=' ';
252246
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
253247
if (err!=UNZ_OK)
@@ -258,7 +252,7 @@ int do_list(uf)
258252
if (file_info.uncompressed_size>0)
259253
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
260254

261-
/* display a '*' if the file is crypted */
255+
/* display a '*' if the file is encrypted */
262256
if ((file_info.flag & 1) != 0)
263257
charCrypt='*';
264258

@@ -308,12 +302,7 @@ int do_list(uf)
308302
}
309303

310304

311-
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
312-
unzFile uf;
313-
const int* popt_extract_without_path;
314-
int* popt_overwrite;
315-
const char* password;
316-
{
305+
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
317306
char filename_inzip[256];
318307
char* filename_withoutpath;
319308
char* p;
@@ -323,7 +312,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
323312
uInt size_buf;
324313

325314
unz_file_info64 file_info;
326-
uLong ratio=0;
327315
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
328316

329317
if (err!=UNZ_OK)
@@ -438,7 +426,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
438426
break;
439427
}
440428
if (err>0)
441-
if (fwrite(buf,err,1,fout)!=1)
429+
if (fwrite(buf,(unsigned)err,1,fout)!=1)
442430
{
443431
printf("error in writing extracted file\n");
444432
err=UNZ_ERRNO;
@@ -471,16 +459,10 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
471459
}
472460

473461

474-
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
475-
unzFile uf;
476-
int opt_extract_without_path;
477-
int opt_overwrite;
478-
const char* password;
479-
{
462+
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
480463
uLong i;
481464
unz_global_info64 gi;
482465
int err;
483-
FILE* fout=NULL;
484466

485467
err = unzGetGlobalInfo64(uf,&gi);
486468
if (err!=UNZ_OK)
@@ -507,14 +489,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
507489
return 0;
508490
}
509491

510-
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
511-
unzFile uf;
512-
const char* filename;
513-
int opt_extract_without_path;
514-
int opt_overwrite;
515-
const char* password;
516-
{
517-
int err = UNZ_OK;
492+
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
518493
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
519494
{
520495
printf("file %s not found in the zipfile\n",filename);
@@ -530,10 +505,7 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
530505
}
531506

532507

533-
int main(argc,argv)
534-
int argc;
535-
char *argv[];
536-
{
508+
int main(int argc, char *argv[]) {
537509
const char *zipfilename=NULL;
538510
const char *filename_to_extract=NULL;
539511
const char *password=NULL;
@@ -564,7 +536,7 @@ int main(argc,argv)
564536

565537
while ((*p)!='\0')
566538
{
567-
char c=*(p++);;
539+
char c=*(p++);
568540
if ((c=='l') || (c=='L'))
569541
opt_do_list = 1;
570542
if ((c=='v') || (c=='V'))
@@ -606,7 +578,7 @@ int main(argc,argv)
606578
# endif
607579

608580
strncpy(filename_try, zipfilename,MAXFILENAME-1);
609-
/* strncpy doesnt append the trailing NULL, of the string is too long. */
581+
/* strncpy doesn't append the trailing NULL, of the string is too long. */
610582
filename_try[ MAXFILENAME ] = '\0';
611583

612584
# ifdef USEWIN32IOAPI

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

+37-48
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#endif
2828
#endif
2929

30-
#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
30+
#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || defined(__Fuchsia__) || defined(__ANDROID_API__)
3131
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
3232
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
3333
#define FTELLO_FUNC(stream) ftello(stream)
@@ -70,11 +70,9 @@
7070
#define MAXFILENAME (256)
7171

7272
#ifdef _WIN32
73-
uLong filetime(f, tmzip, dt)
74-
char *f; /* name of file to get info on */
75-
tm_zip *tmzip; /* return value: access, modific. and creation times */
76-
uLong *dt; /* dostime */
77-
{
73+
/* f: name of file to get info on, tmzip: return value: access,
74+
modification and creation times, dt: dostime */
75+
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
7876
int ret = 0;
7977
{
8078
FILETIME ftLocal;
@@ -94,11 +92,10 @@ uLong filetime(f, tmzip, dt)
9492
}
9593
#else
9694
#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
97-
uLong filetime(f, tmzip, dt)
98-
char *f; /* name of file to get info on */
99-
tm_zip *tmzip; /* return value: access, modific. and creation times */
100-
uLong *dt; /* dostime */
101-
{
95+
/* f: name of file to get info on, tmzip: return value: access,
96+
modification and creation times, dt: dostime */
97+
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
98+
(void)dt;
10299
int ret=0;
103100
struct stat s; /* results of stat() */
104101
struct tm* filedate;
@@ -107,12 +104,12 @@ uLong filetime(f, tmzip, dt)
107104
if (strcmp(f,"-")!=0)
108105
{
109106
char name[MAXFILENAME+1];
110-
int len = strlen(f);
107+
size_t len = strlen(f);
111108
if (len > MAXFILENAME)
112109
len = MAXFILENAME;
113110

114111
strncpy(name, f,MAXFILENAME-1);
115-
/* strncpy doesnt append the trailing NULL, of the string is too long. */
112+
/* strncpy doesn't append the trailing NULL, of the string is too long. */
116113
name[ MAXFILENAME ] = '\0';
117114

118115
if (name[len - 1] == '/')
@@ -136,11 +133,12 @@ uLong filetime(f, tmzip, dt)
136133
return ret;
137134
}
138135
#else
139-
uLong filetime(f, tmzip, dt)
140-
char *f; /* name of file to get info on */
141-
tm_zip *tmzip; /* return value: access, modific. and creation times */
142-
uLong *dt; /* dostime */
143-
{
136+
/* f: name of file to get info on, tmzip: return value: access,
137+
modification and creation times, dt: dostime */
138+
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
139+
(void)f;
140+
(void)tmzip;
141+
(void)dt;
144142
return 0;
145143
}
146144
#endif
@@ -149,9 +147,7 @@ uLong filetime(f, tmzip, dt)
149147

150148

151149

152-
int check_exist_file(filename)
153-
const char* filename;
154-
{
150+
static int check_exist_file(const char* filename) {
155151
FILE* ftestexist;
156152
int ret = 1;
157153
ftestexist = FOPEN_FUNC(filename,"rb");
@@ -162,14 +158,12 @@ int check_exist_file(filename)
162158
return ret;
163159
}
164160

165-
void do_banner()
166-
{
161+
static void do_banner(void) {
167162
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
168163
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
169164
}
170165

171-
void do_help()
172-
{
166+
static void do_help(void) {
173167
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
174168
" -o Overwrite existing file.zip\n" \
175169
" -a Append to existing file.zip\n" \
@@ -181,14 +175,13 @@ void do_help()
181175

182176
/* calculate the CRC32 of a file,
183177
because to encrypt a file, we need known the CRC32 of the file before */
184-
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
185-
{
178+
static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
186179
unsigned long calculate_crc=0;
187180
int err=ZIP_OK;
188181
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
189182

190183
unsigned long size_read = 0;
191-
unsigned long total_read = 0;
184+
/* unsigned long total_read = 0; */
192185
if (fin==NULL)
193186
{
194187
err = ZIP_ERRNO;
@@ -198,7 +191,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
198191
do
199192
{
200193
err = ZIP_OK;
201-
size_read = (int)fread(buf,1,size_buf,fin);
194+
size_read = fread(buf,1,size_buf,fin);
202195
if (size_read < size_buf)
203196
if (feof(fin)==0)
204197
{
@@ -207,8 +200,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
207200
}
208201

209202
if (size_read>0)
210-
calculate_crc = crc32(calculate_crc,buf,size_read);
211-
total_read += size_read;
203+
calculate_crc = crc32_z(calculate_crc,buf,size_read);
204+
/* total_read += size_read; */
212205

213206
} while ((err == ZIP_OK) && (size_read>0));
214207

@@ -220,18 +213,17 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
220213
return err;
221214
}
222215

223-
int isLargeFile(const char* filename)
224-
{
216+
static int isLargeFile(const char* filename) {
225217
int largeFile = 0;
226218
ZPOS64_T pos = 0;
227219
FILE* pFile = FOPEN_FUNC(filename, "rb");
228220

229221
if(pFile != NULL)
230222
{
231-
int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
232-
pos = FTELLO_FUNC(pFile);
223+
FSEEKO_FUNC(pFile, 0, SEEK_END);
224+
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
233225

234-
printf("File : %s is %lld bytes\n", filename, pos);
226+
printf("File : %s is %llu bytes\n", filename, pos);
235227

236228
if(pos >= 0xffffffff)
237229
largeFile = 1;
@@ -242,10 +234,7 @@ int isLargeFile(const char* filename)
242234
return largeFile;
243235
}
244236

245-
int main(argc,argv)
246-
int argc;
247-
char *argv[];
248-
{
237+
int main(int argc, char *argv[]) {
249238
int i;
250239
int opt_overwrite=0;
251240
int opt_compress_level=Z_DEFAULT_COMPRESSION;
@@ -254,7 +243,7 @@ int main(argc,argv)
254243
char filename_try[MAXFILENAME+16];
255244
int zipok;
256245
int err=0;
257-
int size_buf=0;
246+
size_t size_buf=0;
258247
void* buf=NULL;
259248
const char* password=NULL;
260249

@@ -275,7 +264,7 @@ int main(argc,argv)
275264

276265
while ((*p)!='\0')
277266
{
278-
char c=*(p++);;
267+
char c=*(p++);
279268
if ((c=='o') || (c=='O'))
280269
opt_overwrite = 1;
281270
if ((c=='a') || (c=='A'))
@@ -321,7 +310,7 @@ int main(argc,argv)
321310

322311
zipok = 1 ;
323312
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
324-
/* strncpy doesnt append the trailing NULL, of the string is too long. */
313+
/* strncpy doesn't append the trailing NULL, of the string is too long. */
325314
filename_try[ MAXFILENAME ] = '\0';
326315

327316
len=(int)strlen(filename_try);
@@ -391,11 +380,11 @@ int main(argc,argv)
391380
((argv[i][1]=='o') || (argv[i][1]=='O') ||
392381
(argv[i][1]=='a') || (argv[i][1]=='A') ||
393382
(argv[i][1]=='p') || (argv[i][1]=='P') ||
394-
((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
383+
((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
395384
(strlen(argv[i]) == 2)))
396385
{
397-
FILE * fin;
398-
int size_read;
386+
FILE * fin = NULL;
387+
size_t size_read;
399388
const char* filenameinzip = argv[i];
400389
const char *savefilenameinzip;
401390
zip_fileinfo zi;
@@ -471,7 +460,7 @@ int main(argc,argv)
471460
do
472461
{
473462
err = ZIP_OK;
474-
size_read = (int)fread(buf,1,size_buf,fin);
463+
size_read = fread(buf,1,size_buf,fin);
475464
if (size_read < size_buf)
476465
if (feof(fin)==0)
477466
{
@@ -481,7 +470,7 @@ int main(argc,argv)
481470

482471
if (size_read>0)
483472
{
484-
err = zipWriteInFileInZip (zf,buf,size_read);
473+
err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
485474
if (err<0)
486475
{
487476
printf("error in writing %s in the zipfile\n",

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
2828
} while(0)
2929

30-
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
31-
const char* file;
32-
const char* fileOut;
33-
const char* fileOutTmp;
34-
uLong* nRecovered;
35-
uLong* bytesRecovered;
36-
{
30+
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
3731
int err = Z_OK;
3832
FILE* fpZip = fopen(file, "rb");
3933
FILE* fpOut = fopen(fileOut, "wb");

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

+195-314
Large diffs are not rendered by default.

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

+74-74
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ typedef voidp unzFile;
8383
/* tm_unz contain date/time info */
8484
typedef struct tm_unz_s
8585
{
86-
uInt tm_sec; /* seconds after the minute - [0,59] */
87-
uInt tm_min; /* minutes after the hour - [0,59] */
88-
uInt tm_hour; /* hours since midnight - [0,23] */
89-
uInt tm_mday; /* day of the month - [1,31] */
90-
uInt tm_mon; /* months since January - [0,11] */
91-
uInt tm_year; /* years - [1980..2044] */
86+
int tm_sec; /* seconds after the minute - [0,59] */
87+
int tm_min; /* minutes after the hour - [0,59] */
88+
int tm_hour; /* hours since midnight - [0,23] */
89+
int tm_mday; /* day of the month - [1,31] */
90+
int tm_mon; /* months since January - [0,11] */
91+
int tm_year; /* years - [1980..2044] */
9292
} tm_unz;
9393

9494
/* unz_global_info structure contain global data about the ZIPfile
@@ -150,21 +150,21 @@ typedef struct unz_file_info_s
150150
tm_unz tmu_date;
151151
} unz_file_info;
152152

153-
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
154-
const char* fileName2,
155-
int iCaseSensitivity));
153+
extern int ZEXPORT unzStringFileNameCompare(const char* fileName1,
154+
const char* fileName2,
155+
int iCaseSensitivity);
156156
/*
157-
Compare two filename (fileName1,fileName2).
158-
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
159-
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
157+
Compare two filenames (fileName1,fileName2).
158+
If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
159+
If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
160160
or strcasecmp)
161-
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
161+
If iCaseSensitivity = 0, case sensitivity is default of your operating system
162162
(like 1 on Unix, 2 on Windows)
163163
*/
164164

165165

166-
extern unzFile ZEXPORT unzOpen OF((const char *path));
167-
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
166+
extern unzFile ZEXPORT unzOpen(const char *path);
167+
extern unzFile ZEXPORT unzOpen64(const void *path);
168168
/*
169169
Open a Zip file. path contain the full pathname (by example,
170170
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
@@ -181,41 +181,41 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path));
181181
*/
182182

183183

184-
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
185-
zlib_filefunc_def* pzlib_filefunc_def));
184+
extern unzFile ZEXPORT unzOpen2(const char *path,
185+
zlib_filefunc_def* pzlib_filefunc_def);
186186
/*
187187
Open a Zip file, like unzOpen, but provide a set of file low level API
188188
for read/write the zip file (see ioapi.h)
189189
*/
190190

191-
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
192-
zlib_filefunc64_def* pzlib_filefunc_def));
191+
extern unzFile ZEXPORT unzOpen2_64(const void *path,
192+
zlib_filefunc64_def* pzlib_filefunc_def);
193193
/*
194194
Open a Zip file, like unz64Open, but provide a set of file low level API
195195
for read/write the zip file (see ioapi.h)
196196
*/
197197

198-
extern int ZEXPORT unzClose OF((unzFile file));
198+
extern int ZEXPORT unzClose(unzFile file);
199199
/*
200200
Close a ZipFile opened with unzOpen.
201201
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
202202
these files MUST be closed with unzCloseCurrentFile before call unzClose.
203203
return UNZ_OK if there is no problem. */
204204

205-
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
206-
unz_global_info *pglobal_info));
205+
extern int ZEXPORT unzGetGlobalInfo(unzFile file,
206+
unz_global_info *pglobal_info);
207207

208-
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
209-
unz_global_info64 *pglobal_info));
208+
extern int ZEXPORT unzGetGlobalInfo64(unzFile file,
209+
unz_global_info64 *pglobal_info);
210210
/*
211211
Write info about the ZipFile in the *pglobal_info structure.
212212
No preparation of the structure is needed
213213
return UNZ_OK if there is no problem. */
214214

215215

216-
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
217-
char *szComment,
218-
uLong uSizeBuf));
216+
extern int ZEXPORT unzGetGlobalComment(unzFile file,
217+
char *szComment,
218+
uLong uSizeBuf);
219219
/*
220220
Get the global comment string of the ZipFile, in the szComment buffer.
221221
uSizeBuf is the size of the szComment buffer.
@@ -226,22 +226,22 @@ extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
226226
/***************************************************************************/
227227
/* Unzip package allow you browse the directory of the zipfile */
228228

229-
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
229+
extern int ZEXPORT unzGoToFirstFile(unzFile file);
230230
/*
231231
Set the current file of the zipfile to the first file.
232232
return UNZ_OK if there is no problem
233233
*/
234234

235-
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
235+
extern int ZEXPORT unzGoToNextFile(unzFile file);
236236
/*
237237
Set the current file of the zipfile to the next file.
238238
return UNZ_OK if there is no problem
239239
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
240240
*/
241241

242-
extern int ZEXPORT unzLocateFile OF((unzFile file,
243-
const char *szFileName,
244-
int iCaseSensitivity));
242+
extern int ZEXPORT unzLocateFile(unzFile file,
243+
const char *szFileName,
244+
int iCaseSensitivity);
245245
/*
246246
Try locate the file szFileName in the zipfile.
247247
For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -285,26 +285,26 @@ extern int ZEXPORT unzGoToFilePos64(
285285

286286
/* ****************************************** */
287287

288-
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
289-
unz_file_info64 *pfile_info,
290-
char *szFileName,
291-
uLong fileNameBufferSize,
292-
void *extraField,
293-
uLong extraFieldBufferSize,
294-
char *szComment,
295-
uLong commentBufferSize));
296-
297-
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
298-
unz_file_info *pfile_info,
299-
char *szFileName,
300-
uLong fileNameBufferSize,
301-
void *extraField,
302-
uLong extraFieldBufferSize,
303-
char *szComment,
304-
uLong commentBufferSize));
288+
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
289+
unz_file_info64 *pfile_info,
290+
char *szFileName,
291+
uLong fileNameBufferSize,
292+
void *extraField,
293+
uLong extraFieldBufferSize,
294+
char *szComment,
295+
uLong commentBufferSize);
296+
297+
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
298+
unz_file_info *pfile_info,
299+
char *szFileName,
300+
uLong fileNameBufferSize,
301+
void *extraField,
302+
uLong extraFieldBufferSize,
303+
char *szComment,
304+
uLong commentBufferSize);
305305
/*
306306
Get Info about the current file
307-
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
307+
if pfile_info!=NULL, the *pfile_info structure will contain some info about
308308
the current file
309309
if szFileName!=NULL, the filemane string will be copied in szFileName
310310
(fileNameBufferSize is the size of the buffer)
@@ -318,7 +318,7 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
318318

319319
/** Addition for GDAL : START */
320320

321-
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
321+
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
322322

323323
/** Addition for GDAL : END */
324324

@@ -328,24 +328,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
328328
from it, and close it (you can close it before reading all the file)
329329
*/
330330

331-
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
331+
extern int ZEXPORT unzOpenCurrentFile(unzFile file);
332332
/*
333333
Open for reading data the current file in the zipfile.
334334
If there is no error, the return value is UNZ_OK.
335335
*/
336336

337-
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
338-
const char* password));
337+
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file,
338+
const char* password);
339339
/*
340340
Open for reading data the current file in the zipfile.
341341
password is a crypting password
342342
If there is no error, the return value is UNZ_OK.
343343
*/
344344

345-
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
346-
int* method,
347-
int* level,
348-
int raw));
345+
extern int ZEXPORT unzOpenCurrentFile2(unzFile file,
346+
int* method,
347+
int* level,
348+
int raw);
349349
/*
350350
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
351351
if raw==1
@@ -355,11 +355,11 @@ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
355355
but you CANNOT set method parameter as NULL
356356
*/
357357

358-
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
359-
int* method,
360-
int* level,
361-
int raw,
362-
const char* password));
358+
extern int ZEXPORT unzOpenCurrentFile3(unzFile file,
359+
int* method,
360+
int* level,
361+
int raw,
362+
const char* password);
363363
/*
364364
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
365365
if raw==1
@@ -370,41 +370,41 @@ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
370370
*/
371371

372372

373-
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
373+
extern int ZEXPORT unzCloseCurrentFile(unzFile file);
374374
/*
375375
Close the file in zip opened with unzOpenCurrentFile
376376
Return UNZ_CRCERROR if all the file was read but the CRC is not good
377377
*/
378378

379-
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
380-
voidp buf,
381-
unsigned len));
379+
extern int ZEXPORT unzReadCurrentFile(unzFile file,
380+
voidp buf,
381+
unsigned len);
382382
/*
383383
Read bytes from the current file (opened by unzOpenCurrentFile)
384384
buf contain buffer where data must be copied
385385
len the size of buf.
386386
387-
return the number of byte copied if somes bytes are copied
387+
return the number of byte copied if some bytes are copied
388388
return 0 if the end of file was reached
389389
return <0 with error code if there is an error
390390
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
391391
*/
392392

393-
extern z_off_t ZEXPORT unztell OF((unzFile file));
393+
extern z_off_t ZEXPORT unztell(unzFile file);
394394

395-
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
395+
extern ZPOS64_T ZEXPORT unztell64(unzFile file);
396396
/*
397397
Give the current position in uncompressed data
398398
*/
399399

400-
extern int ZEXPORT unzeof OF((unzFile file));
400+
extern int ZEXPORT unzeof(unzFile file);
401401
/*
402402
return 1 if the end of file was reached, 0 elsewhere
403403
*/
404404

405-
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
406-
voidp buf,
407-
unsigned len));
405+
extern int ZEXPORT unzGetLocalExtrafield(unzFile file,
406+
voidp buf,
407+
unsigned len);
408408
/*
409409
Read extra field from the current file (opened by unzOpenCurrentFile)
410410
This is the local-header version of the extra field (sometimes, there is

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

+145-207
Large diffs are not rendered by default.

‎deps/zlib/contrib/minizip/zip.h

+156-154
Large diffs are not rendered by default.

‎deps/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc

+72-18
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,96 @@
2323

2424
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
2525
FuzzedDataProvider fdp(data, size);
26-
int level = fdp.PickValueInArray({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
26+
int level = fdp.PickValueInArray({-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
2727
int windowBits = fdp.PickValueInArray({9, 10, 11, 12, 13, 14, 15});
2828
int memLevel = fdp.PickValueInArray({1, 2, 3, 4, 5, 6, 7, 8, 9});
2929
int strategy = fdp.PickValueInArray(
3030
{Z_DEFAULT_STRATEGY, Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED});
31-
std::vector<uint8_t> src = fdp.ConsumeRemainingBytes<uint8_t>();
31+
32+
if (fdp.ConsumeBool()) {
33+
// Gzip wrapper.
34+
windowBits += 16;
35+
} else if (fdp.ConsumeBool()) {
36+
// Raw deflate.
37+
windowBits *= -1;
38+
} else {
39+
// Default: zlib wrapper.
40+
}
41+
42+
std::vector<uint8_t> src;
43+
std::vector<uint8_t> compressed;
44+
static const int kMinChunk = 1;
45+
static const int kMaxChunk = 512 * 1024;
3246

3347
z_stream stream;
3448
stream.zalloc = Z_NULL;
3549
stream.zfree = Z_NULL;
36-
37-
// Compress the data one byte at a time to exercise the streaming code.
3850
int ret =
3951
deflateInit2(&stream, level, Z_DEFLATED, windowBits, memLevel, strategy);
4052
ASSERT(ret == Z_OK);
4153

42-
size_t deflate_bound = deflateBound(&stream, src.size());
54+
// Stream with random-sized input and output buffers.
55+
while (fdp.ConsumeBool()) {
56+
if (fdp.ConsumeBool()) {
57+
// Check that copying the stream's state works. Gating this behind
58+
// ConsumeBool() allows to interleave deflateCopy() with deflate() calls
59+
// to better stress the code.
60+
z_stream stream2;
61+
ASSERT(deflateCopy(&stream2, &stream) == Z_OK);
62+
ret = deflateEnd(&stream);
63+
ASSERT(ret == Z_OK || Z_DATA_ERROR);
64+
memset(&stream, 0xff, sizeof(stream));
65+
66+
ASSERT(deflateCopy(&stream, &stream2) == Z_OK);
67+
ret = deflateEnd(&stream2);
68+
ASSERT(ret == Z_OK || Z_DATA_ERROR);
69+
}
4370

44-
std::vector<uint8_t> compressed(src.size() * 2 + 1000);
45-
stream.next_out = compressed.data();
46-
stream.avail_out = compressed.size();
47-
for (uint8_t b : src) {
48-
stream.next_in = &b;
49-
stream.avail_in = 1;
71+
std::vector<uint8_t> src_chunk = fdp.ConsumeBytes<uint8_t>(
72+
fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk));
73+
std::vector<uint8_t> out_chunk(
74+
fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk));
75+
stream.next_in = src_chunk.data();
76+
stream.avail_in = src_chunk.size();
77+
stream.next_out = out_chunk.data();
78+
stream.avail_out = out_chunk.size();
5079
ret = deflate(&stream, Z_NO_FLUSH);
51-
ASSERT(ret == Z_OK);
80+
ASSERT(ret == Z_OK || ret == Z_BUF_ERROR);
81+
82+
src.insert(src.end(), src_chunk.begin(), src_chunk.end() - stream.avail_in);
83+
compressed.insert(compressed.end(), out_chunk.begin(),
84+
out_chunk.end() - stream.avail_out);
85+
}
86+
// Finish up.
87+
while (true) {
88+
std::vector<uint8_t> out_chunk(
89+
fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk));
90+
stream.next_in = Z_NULL;
91+
stream.avail_in = 0;
92+
stream.next_out = out_chunk.data();
93+
stream.avail_out = out_chunk.size();
94+
ret = deflate(&stream, Z_FINISH);
95+
compressed.insert(compressed.end(), out_chunk.begin(),
96+
out_chunk.end() - stream.avail_out);
97+
if (ret == Z_STREAM_END) {
98+
break;
99+
}
100+
ASSERT(ret == Z_OK || Z_BUF_ERROR);
52101
}
53-
stream.next_in = Z_NULL;
54-
stream.avail_in = 0;
55-
ret = deflate(&stream, Z_FINISH);
56-
ASSERT(ret == Z_STREAM_END);
57-
compressed.resize(compressed.size() - stream.avail_out);
58102
deflateEnd(&stream);
59103

60-
// Check that the bound was correct.
104+
// Check deflateBound().
105+
// Use a newly initialized stream since computing the bound on a "used" stream
106+
// may not yield a correct result (https://github.com/madler/zlib/issues/944).
107+
z_stream bound_stream;
108+
bound_stream.zalloc = Z_NULL;
109+
bound_stream.zfree = Z_NULL;
110+
ret = deflateInit2(&bound_stream, level, Z_DEFLATED, windowBits, memLevel,
111+
strategy);
112+
ASSERT(ret == Z_OK);
113+
size_t deflate_bound = deflateBound(&bound_stream, src.size());
61114
ASSERT(compressed.size() <= deflate_bound);
115+
deflateEnd(&bound_stream);
62116

63117
// Verify that the data decompresses correctly.
64118
ret = inflateInit2(&stream, windowBits);

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

+65
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,71 @@ TEST(ZlibTest, DeflateCopy) {
10801080
0);
10811081
}
10821082

1083+
TEST(ZlibTest, GzipStored) {
1084+
// Check that deflating uncompressed blocks with a gzip header doesn't write
1085+
// out of bounds (crbug.com/325990053).
1086+
z_stream stream;
1087+
stream.zalloc = Z_NULL;
1088+
stream.zfree = Z_NULL;
1089+
static const int kGzipWrapper = 16;
1090+
int ret = deflateInit2(&stream, Z_NO_COMPRESSION, Z_DEFLATED,
1091+
9 + kGzipWrapper, 9, Z_DEFAULT_STRATEGY);
1092+
ASSERT_EQ(ret, Z_OK);
1093+
1094+
const std::vector<uint8_t> src(512 * 1024);
1095+
stream.next_in = (unsigned char*)src.data();
1096+
stream.avail_in = src.size();
1097+
1098+
std::vector<uint8_t> out(1000);
1099+
stream.next_out = (unsigned char*)out.data();
1100+
stream.avail_out = out.size();
1101+
1102+
ret = deflate(&stream, Z_NO_FLUSH);
1103+
ASSERT_EQ(ret, Z_OK);
1104+
1105+
deflateEnd(&stream);
1106+
}
1107+
1108+
TEST(ZlibTest, DeflateBound) {
1109+
// Check that the deflateBound() isn't too low when using non-default
1110+
// parameters (crbug.com/40270738).
1111+
const int level = 9;
1112+
const int windowBits = 15;
1113+
const int memLevel = 1;
1114+
const int strategy = Z_FIXED;
1115+
const uint8_t src[] = {
1116+
49, 255, 255, 20, 45, 49, 167, 56, 55, 255, 255, 255, 223, 255, 49,
1117+
255, 3, 78, 0, 0, 141, 253, 209, 163, 29, 195, 43, 60, 199, 123,
1118+
112, 35, 134, 13, 148, 102, 212, 4, 184, 103, 7, 102, 225, 102, 156,
1119+
164, 78, 48, 70, 49, 125, 162, 55, 116, 161, 174, 83, 0, 59, 0,
1120+
225, 140, 0, 0, 63, 63, 4, 15, 198, 30, 126, 196, 33, 99, 135,
1121+
41, 192, 82, 28, 105, 216, 170, 221, 14, 61, 1, 0, 0, 22, 195,
1122+
45, 53, 244, 163, 167, 158, 229, 68, 18, 112, 49, 174, 43, 75, 90,
1123+
161, 85, 19, 36, 163, 118, 228, 169, 180, 161, 237, 234, 253, 197, 234,
1124+
66, 106, 12, 42, 124, 96, 160, 144, 183, 194, 157, 167, 202, 217};
1125+
1126+
z_stream stream;
1127+
stream.zalloc = Z_NULL;
1128+
stream.zfree = Z_NULL;
1129+
int ret =
1130+
deflateInit2(&stream, level, Z_DEFLATED, windowBits, memLevel, strategy);
1131+
ASSERT_EQ(ret, Z_OK);
1132+
size_t deflate_bound = deflateBound(&stream, sizeof(src));
1133+
1134+
uint8_t out[sizeof(src) * 10];
1135+
stream.next_in = (uint8_t*)src;
1136+
stream.avail_in = sizeof(src);
1137+
stream.next_out = out;
1138+
stream.avail_out = sizeof(out);
1139+
ret = deflate(&stream, Z_FINISH);
1140+
ASSERT_EQ(ret, Z_STREAM_END);
1141+
1142+
size_t out_size = sizeof(out) - stream.avail_out;
1143+
EXPECT_LE(out_size, deflate_bound);
1144+
1145+
deflateEnd(&stream);
1146+
}
1147+
10831148
// TODO(gustavoa): make these tests run standalone.
10841149
#ifndef CMAKE_STANDALONE_UNITTESTS
10851150

‎deps/zlib/crc_folding.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s,
403403
}
404404
#endif
405405

406-
_mm_storeu_si128((__m128i *)dst, xmm_crc_part);
406+
zmemcpy(dst, src, len); /* TODO: Possibly generate more efficient code. */
407407
partial_fold(s, len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3,
408408
&xmm_crc_part);
409409
done:

‎deps/zlib/deflate.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,12 @@ int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version,
387387
/* To do: ignore strm->next_in if we use it as window */
388388
}
389389

390+
#define WINDOW_PADDING 8
391+
390392
/* ========================================================================= */
391393
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
392394
int windowBits, int memLevel, int strategy,
393395
const char *version, int stream_size) {
394-
unsigned window_padding = 8;
395396
deflate_state *s;
396397
int wrap = 1;
397398
static const char my_version[] = ZLIB_VERSION;
@@ -477,11 +478,11 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
477478
s->hash_shift = ((s->hash_bits + MIN_MATCH-1) / MIN_MATCH);
478479

479480
s->window = (Bytef *) ZALLOC(strm,
480-
s->w_size + window_padding,
481+
s->w_size + WINDOW_PADDING,
481482
2*sizeof(Byte));
482483
/* Avoid use of unitialized values in the window, see crbug.com/1137613 and
483484
* crbug.com/1144420 */
484-
zmemzero(s->window, (s->w_size + window_padding) * (2 * sizeof(Byte)));
485+
zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte)));
485486
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
486487
/* Avoid use of uninitialized value, see:
487488
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360
@@ -923,6 +924,12 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
923924
wraplen = 6;
924925
}
925926

927+
/* With Chromium's hashing, s->hash_bits may not correspond to the
928+
memLevel, making the computations below incorrect. Return the
929+
conservative bound. */
930+
if (s->chromium_zlib_hash)
931+
return (fixedlen > storelen ? fixedlen : storelen) + wraplen;
932+
926933
/* if not default parameters, return one of the conservative bounds */
927934
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
928935
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
@@ -1342,7 +1349,9 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
13421349
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
13431350
ds->strm = dest;
13441351

1345-
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
1352+
ds->window = (Bytef *) ZALLOC(dest,
1353+
ds->w_size + WINDOW_PADDING,
1354+
2*sizeof(Byte));
13461355
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
13471356
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
13481357
#ifdef LIT_MEM
@@ -1357,7 +1366,8 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
13571366
return Z_MEM_ERROR;
13581367
}
13591368
/* following zmemcpy do not work for 16-bit MSDOS */
1360-
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
1369+
zmemcpy(ds->window, ss->window,
1370+
(ds->w_size + WINDOW_PADDING) * 2 * sizeof(Byte));
13611371
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
13621372
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
13631373
#ifdef LIT_MEM

‎deps/zlib/google/zip_internal.cc

+6-7
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,12 @@ zip_fileinfo TimeToZipFileInfo(const base::Time& file_time) {
260260
// It assumes that dates below 1980 are in the double digit format.
261261
// Hence the fail safe option is to leave the date unset. Some programs
262262
// might show the unset date as 1980-0-0 which is invalid.
263-
zip_info.tmz_date = {
264-
.tm_sec = static_cast<uInt>(file_time_parts.second),
265-
.tm_min = static_cast<uInt>(file_time_parts.minute),
266-
.tm_hour = static_cast<uInt>(file_time_parts.hour),
267-
.tm_mday = static_cast<uInt>(file_time_parts.day_of_month),
268-
.tm_mon = static_cast<uInt>(file_time_parts.month - 1),
269-
.tm_year = static_cast<uInt>(file_time_parts.year)};
263+
zip_info.tmz_date.tm_year = file_time_parts.year;
264+
zip_info.tmz_date.tm_mon = file_time_parts.month - 1;
265+
zip_info.tmz_date.tm_mday = file_time_parts.day_of_month;
266+
zip_info.tmz_date.tm_hour = file_time_parts.hour;
267+
zip_info.tmz_date.tm_min = file_time_parts.minute;
268+
zip_info.tmz_date.tm_sec = file_time_parts.second;
270269
}
271270

272271
return zip_info;

‎deps/zlib/google/zip_reader_unittest.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ TEST_F(ZipReaderTest, Open_ExistentButNonZipFile) {
234234
TEST_F(ZipReaderTest, Open_EmptyFile) {
235235
ZipReader reader;
236236
EXPECT_FALSE(reader.ok());
237-
EXPECT_FALSE(reader.Open(data_dir_.AppendASCII("empty.zip")));
238-
EXPECT_FALSE(reader.ok());
237+
EXPECT_TRUE(reader.Open(data_dir_.AppendASCII("empty.zip")));
238+
EXPECT_TRUE(reader.ok());
239+
EXPECT_EQ(0, reader.num_entries());
240+
EXPECT_EQ(nullptr, reader.Next());
239241
}
240242

241243
// Iterate through the contents in the test ZIP archive, and compare that the

‎deps/zlib/patches/0000-build.patch

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1+
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
2+
index 782d32469ae5d..a38881dca90a2 100644
3+
--- a/contrib/minizip/ioapi.c
4+
+++ b/contrib/minizip/ioapi.c
5+
@@ -14,7 +14,7 @@
6+
#define _CRT_SECURE_NO_WARNINGS
7+
#endif
8+
9+
-#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
10+
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
11+
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
12+
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
13+
#define FTELLO_FUNC(stream) ftello(stream)
114
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
2-
index 274f39eb1dd2..246ceb91a139 100644
15+
index 08536e94b8a28..bbd7773e67146 100644
316
--- a/contrib/minizip/iowin32.c
417
+++ b/contrib/minizip/iowin32.c
5-
@@ -26,12 +26,19 @@
18+
@@ -25,7 +25,12 @@
19+
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
620
#endif
721

8-
922
+#ifdef _WIN32_WINNT
1023
+#undef _WIN32_WINNT
1124
+#define _WIN32_WINNT 0x601
1225
+#endif
13-
+
26+
1427
+#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
1528
// see Include/shared/winapifamily.h in the Windows Kit
1629
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
17-
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
30+
31+
@@ -37,6 +42,7 @@
1832
#define IOWIN32_USING_WINRT_API 1
1933
#endif
2034
#endif
2135
+#endif
2236

23-
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
24-
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
25-
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
26-
index bcfb9416ec35..199b4723fcfc 100644
27-
--- a/contrib/minizip/unzip.c
28-
+++ b/contrib/minizip/unzip.c
29-
@@ -1705,11 +1705,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
30-
31-
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
32-
33-
- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
34-
- (!(pfile_in_zip_read_info->raw)))
35-
- pfile_in_zip_read_info->stream.avail_out =
36-
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
37-
-
38-
if ((len>pfile_in_zip_read_info->rest_read_compressed+
39-
pfile_in_zip_read_info->stream.avail_in) &&
40-
(pfile_in_zip_read_info->raw))
37+
typedef struct
38+
{
4139
diff --git a/gzread.c b/gzread.c
4240
index 956b91ea7d9e..832d3ef98c59 100644
4341
--- a/gzread.c

‎deps/zlib/patches/0001-simd.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ index 000000000000..48d77744aaf4
449449
+ }
450450
+#endif
451451
+
452-
+ _mm_storeu_si128((__m128i *)dst, xmm_crc_part);
452+
+ zmemcpy(dst, src, len); /* TODO: Possibly generate more efficient code. */
453453
+ partial_fold(s, len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3,
454454
+ &xmm_crc_part);
455455
+done:

‎deps/zlib/patches/0004-fix-uwp.patch

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
diff --git a/third_party/zlib/contrib/minizip/iowin32.c b/third_party/zlib/contrib/minizip/iowin32.c
2-
index 246ceb91a139..c6bc314b3c28 100644
2+
index bbd7773e67146..3f6867fd7e40b 100644
33
--- a/third_party/zlib/contrib/minizip/iowin32.c
44
+++ b/third_party/zlib/contrib/minizip/iowin32.c
5-
@@ -31,14 +31,12 @@
5+
@@ -30,19 +30,12 @@
66
#define _WIN32_WINNT 0x601
77
#endif
88

99
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
1010
-// see Include/shared/winapifamily.h in the Windows Kit
1111
-#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
12+
-
13+
-#if !defined(WINAPI_FAMILY_ONE_PARTITION)
14+
-#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
15+
-#endif
16+
-
1217
-#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
1318
+#if !defined(IOWIN32_USING_WINRT_API)
1419
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
@@ -18,5 +23,5 @@ index 246ceb91a139..c6bc314b3c28 100644
1823
#endif
1924
-#endif
2025

21-
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
22-
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
26+
typedef struct
27+
{

‎deps/zlib/patches/0008-minizip-zip-unzip-tools.patch

+23-32
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Subject: [PATCH] Build minizip zip and unzip tools
99
2 files changed, 9 insertions(+), 11 deletions(-)
1010

1111
diff --git a/third_party/zlib/contrib/minizip/miniunz.c b/third_party/zlib/contrib/minizip/miniunz.c
12-
index 3d65401be5cd..08737f689a96 100644
12+
index 8ada038dbd4e7..5b4312e5647cd 100644
1313
--- a/third_party/zlib/contrib/minizip/miniunz.c
1414
+++ b/third_party/zlib/contrib/minizip/miniunz.c
1515
@@ -12,7 +12,7 @@
1616
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
1717
*/
18-
18+
1919
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
2020
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__))
2121
#ifndef __USE_FILE_OFFSET64
@@ -24,32 +24,24 @@ index 3d65401be5cd..08737f689a96 100644
2424
@@ -27,7 +27,7 @@
2525
#endif
2626
#endif
27-
28-
-#ifdef __APPLE__
29-
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
27+
28+
-#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
29+
+#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || defined(__Fuchsia__) || defined(__ANDROID_API__)
3030
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
3131
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
3232
#define FTELLO_FUNC(stream) ftello(stream)
33-
@@ -45,6 +45,7 @@
34-
#include <time.h>
35-
#include <errno.h>
36-
#include <fcntl.h>
37-
+#include <sys/stat.h>
38-
39-
#ifdef _WIN32
40-
# include <direct.h>
41-
@@ -97,7 +98,7 @@ void change_file_date(filename,dosdate,tmu_date)
33+
@@ -94,7 +94,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
4234
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
4335
CloseHandle(hFile);
4436
#else
45-
-#ifdef unix || __APPLE__
37+
-#if defined(unix) || defined(__APPLE__)
4638
+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
39+
(void)dosdate;
4740
struct utimbuf ut;
4841
struct tm newdate;
49-
newdate.tm_sec = tmu_date.tm_sec;
50-
@@ -125,11 +126,9 @@ int mymkdir(dirname)
51-
const char* dirname;
52-
{
42+
@@ -125,11 +125,9 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
43+
44+
static int mymkdir(const char* dirname) {
5345
int ret=0;
5446
-#ifdef _WIN32
5547
+#if defined(_WIN32)
@@ -59,16 +51,16 @@ index 3d65401be5cd..08737f689a96 100644
5951
-#elif __APPLE__
6052
+#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
6153
ret = mkdir (dirname,0775);
62-
#endif
63-
return ret;
54+
#else
55+
(void)dirname;
6456
diff --git a/third_party/zlib/contrib/minizip/minizip.c b/third_party/zlib/contrib/minizip/minizip.c
65-
index 4288962ecef0..b794953c5c23 100644
57+
index 26ee8d029efe6..9eb3956a55e00 100644
6658
--- a/third_party/zlib/contrib/minizip/minizip.c
6759
+++ b/third_party/zlib/contrib/minizip/minizip.c
6860
@@ -12,8 +12,7 @@
6961
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
7062
*/
71-
63+
7264
-
7365
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
7466
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__))
@@ -78,21 +70,20 @@ index 4288962ecef0..b794953c5c23 100644
7870
@@ -28,7 +27,7 @@
7971
#endif
8072
#endif
81-
82-
-#ifdef __APPLE__
83-
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
73+
74+
-#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
75+
+#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || defined(__Fuchsia__) || defined(__ANDROID_API__)
8476
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
8577
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
8678
#define FTELLO_FUNC(stream) ftello(stream)
87-
@@ -94,7 +93,7 @@ uLong filetime(f, tmzip, dt)
79+
@@ -92,7 +91,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
8880
return ret;
8981
}
9082
#else
91-
-#ifdef unix || __APPLE__
83+
-#if defined(unix) || defined(__APPLE__)
9284
+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
93-
uLong filetime(f, tmzip, dt)
94-
char *f; /* name of file to get info on */
95-
tm_zip *tmzip; /* return value: access, modific. and creation times */
85+
/* f: name of file to get info on, tmzip: return value: access,
86+
modification and creation times, dt: dostime */
87+
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
9688
--
9789
2.31.1.818.g46aad6cb9e-goog
98-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
commit 764f0715d75c8d49339aa73d0ee2feb75d63473f
2+
Author: joaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>
3+
Date: Wed May 7 20:53:02 2014 +0000
4+
5+
Fixed uncompressing files with wrong uncompressed size set.
6+
7+
A zip file carries some metadata for each archived file, including the total
8+
uncompressed size. If that size was incorrect, therefore the compressed file
9+
being different in size when unpacking, the minizip code would fail with a
10+
CRC error. Every other zip utility handles these files, so should the minizip
11+
code for safety sake.
12+
13+
BUG=359516
14+
15+
Review URL: https://codereview.chromium.org/222243003
16+
17+
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268940 0039d316-1c4b-4281-b951-d872f2087c98
18+
19+
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
20+
index ed763f89f1f87..82275d6c1775d 100644
21+
--- a/third_party/zlib/contrib/minizip/unzip.c
22+
+++ b/third_party/zlib/contrib/minizip/unzip.c
23+
@@ -1572,11 +1572,6 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
24+
25+
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
26+
27+
- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
28+
- (!(pfile_in_zip_read_info->raw)))
29+
- pfile_in_zip_read_info->stream.avail_out =
30+
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
31+
-
32+
if ((len>pfile_in_zip_read_info->rest_read_compressed+
33+
pfile_in_zip_read_info->stream.avail_in) &&
34+
(pfile_in_zip_read_info->raw))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
commit f3ace98803035b8425d127fb3d874dafe0b9475a
2+
Author: Che-yu Wu <cheyuw@google.com>
3+
Date: Mon Aug 6 14:09:22 2018 +0000
4+
5+
Enable traditional PKWARE decryption in zlib/contrib/minizip.
6+
7+
Remove the #define which enables NOUNCRYPT by default.
8+
Correct the value of rest_read_compressed when decompressing an encrypted zip.
9+
10+
Bug: crbug.com/869541
11+
Change-Id: Ia86c1d234a8193f405147d35ad05c29fe86f812d
12+
Reviewed-on: https://chromium-review.googlesource.com/1161109
13+
Reviewed-by: Chris Blume <cblume@chromium.org>
14+
Commit-Queue: Che-yu Wu <cheyuw@google.com>
15+
Cr-Commit-Position: refs/heads/master@{#580862}
16+
17+
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
18+
index 82275d6c1775d..c8a01b23efd42 100644
19+
--- a/third_party/zlib/contrib/minizip/unzip.c
20+
+++ b/third_party/zlib/contrib/minizip/unzip.c
21+
@@ -68,10 +68,6 @@
22+
#include <stdlib.h>
23+
#include <string.h>
24+
25+
-#ifndef NOUNCRYPT
26+
- #define NOUNCRYPT
27+
-#endif
28+
-
29+
#include "zlib.h"
30+
#include "unzip.h"
31+
32+
@@ -1502,6 +1498,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
33+
zdecode(s->keys,s->pcrc_32_tab,source[i]);
34+
35+
s->pfile_in_zip_read->pos_in_zipfile+=12;
36+
+ s->pfile_in_zip_read->rest_read_compressed-=12;
37+
s->encrypted=1;
38+
}
39+
# endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
commit c8834821f452a3d424edd0ed2a1e9ceeda38d0ea
2+
Author: Alex Danilo <adanilo@chromium.org>
3+
Date: Thu May 12 03:29:52 2022 +0000
4+
5+
Extract: Parse Unicode Path Extra field in minizip
6+
7+
Adds parsing of the Info-ZIP Extra field which overrides the
8+
file name in the File Header only if the CRC in the extra field
9+
is a CRC of the file name in the File Header.
10+
11+
See https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
12+
section 4.6.9 for reference.
13+
14+
Also tidied up some whitespace indent.
15+
16+
Bug: 953256, 953599
17+
Tests: Manually tested, auto test in follow on CL
18+
Change-Id: I1283dcb88a203c3bb56c1d9c504035a2e51aecbd
19+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3641742
20+
Reviewed-by: Noel Gordon <noel@chromium.org>
21+
Commit-Queue: Alex Danilo <adanilo@chromium.org>
22+
Cr-Commit-Position: refs/heads/main@{#1002476}
23+
24+
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
25+
index c8a01b23efd42..42677cff82c96 100644
26+
--- a/third_party/zlib/contrib/minizip/unzip.c
27+
+++ b/third_party/zlib/contrib/minizip/unzip.c
28+
@@ -193,6 +193,26 @@ typedef struct
29+
Reads a long in LSB order from the given gz_stream. Sets
30+
*/
31+
32+
+local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,
33+
+ voidpf filestream,
34+
+ int *pi) {
35+
+ unsigned char c;
36+
+ int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
37+
+ if (err==1)
38+
+ {
39+
+ *pi = (int)c;
40+
+ return UNZ_OK;
41+
+ }
42+
+ else
43+
+ {
44+
+ *pi = 0;
45+
+ if (ZERROR64(*pzlib_filefunc_def,filestream))
46+
+ return UNZ_ERRNO;
47+
+ else
48+
+ return UNZ_EOF;
49+
+ }
50+
+}
51+
+
52+
local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
53+
voidpf filestream,
54+
uLong *pX) {
55+
@@ -948,6 +968,62 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
56+
}
57+
58+
}
59+
+ else if (headerId == 0x7075) /* Info-ZIP Unicode Path Extra Field */
60+
+ {
61+
+ int version = 0;
62+
+
63+
+ if (unz64local_getByte(&s->z_filefunc, s->filestream, &version) != UNZ_OK)
64+
+ {
65+
+ err = UNZ_ERRNO;
66+
+ }
67+
+ if (version != 1)
68+
+ {
69+
+ if (ZSEEK64(s->z_filefunc, s->filestream,dataSize - 1, ZLIB_FILEFUNC_SEEK_CUR) != 0)
70+
+ {
71+
+ err = UNZ_ERRNO;
72+
+ }
73+
+ }
74+
+ else
75+
+ {
76+
+ uLong uCrc, uHeaderCrc, fileNameSize;
77+
+
78+
+ if (unz64local_getLong(&s->z_filefunc, s->filestream, &uCrc) != UNZ_OK)
79+
+ {
80+
+ err = UNZ_ERRNO;
81+
+ }
82+
+ uHeaderCrc = crc32(0, (const unsigned char *)szFileName, file_info.size_filename);
83+
+ fileNameSize = dataSize - (2 * sizeof (short) + 1);
84+
+ /* Check CRC against file name in the header. */
85+
+ if (uHeaderCrc != uCrc)
86+
+ {
87+
+ if (ZSEEK64(s->z_filefunc, s->filestream, fileNameSize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
88+
+ {
89+
+ err = UNZ_ERRNO;
90+
+ }
91+
+ }
92+
+ else
93+
+ {
94+
+ uLong uSizeRead;
95+
+
96+
+ if (fileNameSize < fileNameBufferSize)
97+
+ {
98+
+ *(szFileName + fileNameSize) = '\0';
99+
+ uSizeRead = fileNameSize;
100+
+ }
101+
+ else
102+
+ {
103+
+ uSizeRead = fileNameBufferSize;
104+
+ }
105+
+ if ((fileNameSize > 0) && (fileNameBufferSize > 0))
106+
+ {
107+
+ if (ZREAD64(s->z_filefunc, s->filestream, szFileName, uSizeRead) != uSizeRead)
108+
+ {
109+
+ err = UNZ_ERRNO;
110+
+ }
111+
+ }
112+
+ }
113+
+ }
114+
+ }
115+
else
116+
{
117+
if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)

‎deps/zlib/zutil.h

+1-22
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
152152
# endif
153153
#endif
154154

155-
#if defined(MACOS) || defined(TARGET_OS_MAC)
155+
#if defined(MACOS)
156156
# define OS_CODE 7
157-
# ifndef Z_SOLO
158-
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
159-
# include <unix.h> /* for fdopen */
160-
# else
161-
# ifndef fdopen
162-
# define fdopen(fd,mode) NULL /* No fdopen() */
163-
# endif
164-
# endif
165-
# endif
166157
#endif
167158

168159
#ifdef __acorn
@@ -185,18 +176,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
185176
# define OS_CODE 19
186177
#endif
187178

188-
#if defined(_BEOS_) || defined(RISCOS)
189-
# define fdopen(fd,mode) NULL /* No fdopen() */
190-
#endif
191-
192-
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
193-
# if defined(_WIN32_WCE)
194-
# define fdopen(fd,mode) NULL /* No fdopen() */
195-
# else
196-
# define fdopen(fd,type) _fdopen(fd,type)
197-
# endif
198-
#endif
199-
200179
#if defined(__BORLANDC__) && !defined(MSDOS)
201180
#pragma warn -8004
202181
#pragma warn -8008

0 commit comments

Comments
 (0)
Please sign in to comment.