From 420d0d50bcdc47c793157c2f1e143136eafa6500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 31 Mar 2022 14:14:05 +0200 Subject: zlib/minizip: Update to version 1.2.12 Security update, fixes CVE-2018-25032 in zlib. Preliminary assessment doesn't show Godot as affected since we don't seem to call `deflate` with the problematic parameters, but the extent of the vulnerability is not fully clear upstream yet. --- thirdparty/minizip/crypt.h | 19 +- .../minizip/godot-zlib-1.2.4-minizip-seek.patch | 295 --------------------- .../godot-zlib-1.2.4-minizip-unbreak-gentoo.patch | 27 -- thirdparty/minizip/ioapi.c | 18 +- thirdparty/minizip/ioapi.h | 8 +- thirdparty/minizip/patches/godot-seek.patch | 294 ++++++++++++++++++++ thirdparty/minizip/patches/unbreak-gentoo.patch | 27 ++ thirdparty/minizip/unzip.c | 60 +++-- thirdparty/minizip/unzip.h | 12 +- thirdparty/minizip/zip.c | 36 +-- thirdparty/minizip/zip.h | 17 +- 11 files changed, 418 insertions(+), 395 deletions(-) delete mode 100644 thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch delete mode 100644 thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch create mode 100644 thirdparty/minizip/patches/godot-seek.patch create mode 100644 thirdparty/minizip/patches/unbreak-gentoo.patch (limited to 'thirdparty/minizip') diff --git a/thirdparty/minizip/crypt.h b/thirdparty/minizip/crypt.h index 1e9e8200b2..9da15373d8 100644 --- a/thirdparty/minizip/crypt.h +++ b/thirdparty/minizip/crypt.h @@ -38,6 +38,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) * unpredictable manner on 16-bit systems; not a problem * with any known compiler so far, though */ + (void)pcrc_32_tab; temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); } @@ -77,24 +78,24 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) #define zencode(pkeys,pcrc_32_tab,c,t) \ - (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c)) #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED #define RAND_HEAD_LEN 12 /* "last resort" source for second part of crypt seed pattern */ # ifndef ZCR_SEED2 -# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ +# define ZCR_SEED2 3141592654L /* use PI as default pattern */ # endif -static int crypthead(const char* passwd, /* password string */ - unsigned char* buf, /* where to write header */ - int bufSize, - unsigned long* pkeys, - const z_crc_t* pcrc_32_tab, - unsigned long crcForCrypting) +static unsigned crypthead(const char* passwd, /* password string */ + unsigned char* buf, /* where to write header */ + int bufSize, + unsigned long* pkeys, + const z_crc_t* pcrc_32_tab, + unsigned long crcForCrypting) { - int n; /* index in random header */ + unsigned n; /* index in random header */ int t; /* temporary */ int c; /* random byte */ unsigned char header[RAND_HEAD_LEN-2]; /* random header */ diff --git a/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch b/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch deleted file mode 100644 index 2162bafbbc..0000000000 --- a/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch +++ /dev/null @@ -1,295 +0,0 @@ -diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c -index 49958f61f..0afbdc06a 100644 ---- a/thirdparty/minizip/ioapi.c -+++ b/thirdparty/minizip/ioapi.c -@@ -68,8 +68,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef - p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; - p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; - p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; -+ /* GODOT start */ -+ p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem; -+ p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem; -+ /* GODOT end */ - } - -+/* GODOT start */ -+/* -+// GODOT end - - - static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); -@@ -233,3 +240,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; - } -+// GODOT start -+*/ -+/* GODOT end */ -diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h -index 8309c4cf8..f25ab6464 100644 ---- a/thirdparty/minizip/ioapi.h -+++ b/thirdparty/minizip/ioapi.h -@@ -145,6 +145,10 @@ typedef struct zlib_filefunc_def_s - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -+ /* GODOT start */ -+ alloc_func alloc_mem; -+ free_func free_mem; -+ /* GODOT end */ - } zlib_filefunc_def; - - typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); -@@ -161,6 +165,10 @@ typedef struct zlib_filefunc64_def_s - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -+ /* GODOT start */ -+ alloc_func alloc_mem; -+ free_func free_mem; -+ /* GODOT end */ - } zlib_filefunc64_def; - - void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); -diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c -index 7617f41f1..32e27bd65 100644 ---- a/thirdparty/minizip/unzip.c -+++ b/thirdparty/minizip/unzip.c -@@ -157,6 +157,9 @@ typedef struct - uLong compression_method; /* compression method (0==store) */ - ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - int raw; -+ /* GODOT start */ -+ int extra_size; -+ /* GODOT end */ - } file_in_zip64_read_info_s; - - -@@ -606,9 +609,10 @@ local unzFile unzOpenInternal (const void *path, - us.z_filefunc.zseek32_file = NULL; - us.z_filefunc.ztell32_file = NULL; - if (pzlib_filefunc64_32_def==NULL) -- fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); -- else -- us.z_filefunc = *pzlib_filefunc64_32_def; -+ /* GODOT start */ -+ return NULL; // standard i/o not supported -+ us.z_filefunc = *pzlib_filefunc64_32_def; -+ /* GODOT end */ - us.is64bitOpenFunction = is64bitOpenFunction; - - -@@ -800,6 +804,18 @@ extern unzFile ZEXPORT unzOpen64 (const void *path) - return unzOpenInternal(path, NULL, 1); - } - -+/* GODOT start */ -+extern void* unzGetOpaque(unzFile file) { -+ -+ unz64_s* s; -+ if (file==NULL) -+ return NULL; -+ s=(unz64_s*)file; -+ -+ return s->z_filefunc.zfile_func64.opaque; -+}; -+/* GODOT end */ -+ - /* - Close a ZipFile opened with unzOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), -@@ -1018,10 +1034,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, - - if (lSeek!=0) - { -- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) -- lSeek=0; -- else -- err=UNZ_ERRNO; -+ /* GODOT start */ -+ if (lSeek<0) { -+ // WORKAROUND for backwards seeking -+ z_off_t pos = ZTELL64(s->z_filefunc, s->filestream); -+ if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0) -+ lSeek=0; -+ else -+ err=UNZ_ERRNO; -+ } else { -+ if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) -+ lSeek=0; -+ else -+ err=UNZ_ERRNO; -+ } - } - - while(acc < file_info.size_file_extra) -@@ -1575,8 +1601,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, - } - else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) - { -- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; -- pfile_in_zip_read_info->stream.zfree = (free_func)0; -+ /* GODOT start */ -+ pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem; -+ pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem; -+ /* GODOT end */ - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - pfile_in_zip_read_info->stream.next_in = 0; - pfile_in_zip_read_info->stream.avail_in = 0; -@@ -1608,6 +1636,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; -+ /* GODOT start */ -+ pfile_in_zip_read_info->extra_size = iSizeVar; -+ /* GODOT end */ - - s->pfile_in_zip_read = pfile_in_zip_read_info; - s->encrypted = 0; -@@ -1638,6 +1669,85 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, - return UNZ_OK; - } - -+/* GODOT start */ -+extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) { -+ -+ unz64_s* s; -+ file_in_zip64_read_info_s* pfile_in_zip_read_info; -+ if (file==NULL) -+ return UNZ_PARAMERROR; -+ s=(unz64_s*)file; -+ pfile_in_zip_read_info=s->pfile_in_zip_read; -+ -+ if (pfile_in_zip_read_info==NULL) -+ return UNZ_PARAMERROR; -+ -+ if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip -+ return UNZ_INTERNALERROR; -+ }; -+ -+ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) { -+ -+ pfile_in_zip_read_info->rest_read_compressed = -+ s->cur_file_info.compressed_size - pos; -+ pfile_in_zip_read_info->rest_read_uncompressed = -+ s->cur_file_info.uncompressed_size - pos; -+ -+ pfile_in_zip_read_info->pos_in_zipfile = -+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + -+ pfile_in_zip_read_info->extra_size + pos; -+ -+ pfile_in_zip_read_info->stream.avail_in = (uInt)0; -+ pfile_in_zip_read_info->stream.total_out = pos; -+ -+ return ZSEEK64(pfile_in_zip_read_info->z_filefunc, -+ pfile_in_zip_read_info->filestream, -+ pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile, -+ ZLIB_FILEFUNC_SEEK_SET); -+ -+ } else { // gzip -+ -+ if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind -+ -+ pfile_in_zip_read_info->rest_read_compressed = -+ s->cur_file_info.compressed_size ; -+ pfile_in_zip_read_info->rest_read_uncompressed = -+ s->cur_file_info.uncompressed_size ; -+ -+ pfile_in_zip_read_info->pos_in_zipfile = -+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + -+ pfile_in_zip_read_info->extra_size; -+ -+ (void)inflateReset(&pfile_in_zip_read_info->stream); -+ -+ pfile_in_zip_read_info->stream.avail_in = (uInt)0; -+ pfile_in_zip_read_info->stream.total_out = 0; -+ pfile_in_zip_read_info->stream.next_in = 0; -+ }; -+ -+ // not sure where to read, so read on the stack -+ { -+ char buf[512]; -+ int to_read = pos - pfile_in_zip_read_info->stream.total_out; -+ while (to_read) { -+ -+ int len = to_read > sizeof(buf)?sizeof(buf):to_read; -+ int read = unzReadCurrentFile(file, buf, len); -+ if (read < 0) { -+ return read; -+ }; -+ to_read -= read; -+ if (read == UNZ_EOF) { -+ return pos; -+ }; -+ }; -+ }; -+ }; -+ -+ return pos; -+}; -+/* GODOT end */ -+ - extern int ZEXPORT unzOpenCurrentFile (unzFile file) - { - return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); -diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h -index 3183968b7..54e65ad8a 100644 ---- a/thirdparty/minizip/unzip.h -+++ b/thirdparty/minizip/unzip.h -@@ -202,6 +202,10 @@ extern int ZEXPORT unzClose OF((unzFile file)); - these files MUST be closed with unzCloseCurrentFile before call unzClose. - return UNZ_OK if there is no problem. */ - -+/* GODOT start */ -+extern void* unzGetOpaque(unzFile file); -+/* GODOT end */ -+ - extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); - -@@ -390,6 +394,13 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - (UNZ_ERRNO for IO error, or zLib error for uncompress error) - */ - -+/* GODOT start */ -+extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos); -+/* -+ Seek to position in uncompressed data -+*/ -+/* GODOT end */ -+ - extern z_off_t ZEXPORT unztell OF((unzFile file)); - - extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); -diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c -index 3c34fc8bd..d7093e745 100644 ---- a/thirdparty/minizip/zip.c -+++ b/thirdparty/minizip/zip.c -@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl - - ziinit.z_filefunc.zseek32_file = NULL; - ziinit.z_filefunc.ztell32_file = NULL; -- if (pzlib_filefunc64_32_def==NULL) -- fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); -- else -+ /* GODOT start */ -+ if (pzlib_filefunc64_32_def==NULL) { -+ //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); -+ } else -+ /* GODOT end */ - ziinit.z_filefunc = *pzlib_filefunc64_32_def; - - ziinit.filestream = ZOPEN64(ziinit.z_filefunc, -@@ -1210,8 +1212,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, - { - if(zi->ci.method == Z_DEFLATED) - { -- zi->ci.stream.zalloc = (alloc_func)0; -- zi->ci.stream.zfree = (free_func)0; -+ /* GODOT start */ -+ zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem; -+ zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem; -+ /* GODOT end */ - zi->ci.stream.opaque = (voidpf)0; - - if (windowBits>0) diff --git a/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch b/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch deleted file mode 100644 index 9292e32ac6..0000000000 --- a/thirdparty/minizip/godot-zlib-1.2.4-minizip-unbreak-gentoo.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h -index f25ab6464..6043d34ce 100644 ---- a/thirdparty/minizip/ioapi.h -+++ b/thirdparty/minizip/ioapi.h -@@ -44,6 +44,22 @@ - #include - #include "zlib.h" - -+/* GODOT start */ -+/* Mighty Gentoo saves the day by breaking the API of their zlib.h, -+ * removing this definition of OF(args) for no practical reason -+ * worth breaking compatibility with all projects that embed minizip -+ * while trying not to diverge too much from upstream zlib. -+ * Cf. https://github.com/godotengine/godot/issues/10539 -+ * -+ * "By and large, this is good open source behaviour, and fits with -+ * the gentoo _don't fuck with upstream's releases_ philosophy" -+ * -- Gentoo philosopher -+ */ -+#ifndef OF /* function prototypes */ -+ #define OF(args) args -+#endif -+/* GODOT end */ -+ - #if defined(USE_FILE32API) - #define fopen64 fopen - #define ftello64 ftell diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c index 9cb27c16db..db4c33b4b9 100644 --- a/thirdparty/minizip/ioapi.c +++ b/thirdparty/minizip/ioapi.c @@ -58,7 +58,7 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); else { - uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); + uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); if ((tell_uLong) == MAXU32) return (ZPOS64_T)-1; else @@ -101,6 +101,7 @@ static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) { + (void)opaque; FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) @@ -119,6 +120,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) { + (void)opaque; FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) @@ -138,6 +140,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) { + (void)opaque; uLong ret; ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; @@ -145,6 +148,7 @@ static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) { + (void)opaque; uLong ret; ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); return ret; @@ -152,6 +156,7 @@ static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) { + (void)opaque; long ret; ret = ftell((FILE *)stream); return ret; @@ -160,13 +165,15 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) { + (void)opaque; ZPOS64_T ret; - ret = FTELLO_FUNC((FILE *)stream); + ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); return ret; } static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) { + (void)opaque; int fseek_origin=0; long ret; switch (origin) @@ -183,13 +190,14 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs default: return -1; } ret = 0; - if (fseek((FILE *)stream, offset, fseek_origin) != 0) + if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0) ret = -1; return ret; } static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { + (void)opaque; int fseek_origin=0; long ret; switch (origin) @@ -207,7 +215,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0) + if(FSEEKO_FUNC((FILE *)stream, (long)offset, fseek_origin) != 0) ret = -1; return ret; @@ -216,6 +224,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) { + (void)opaque; int ret; ret = fclose((FILE *)stream); return ret; @@ -223,6 +232,7 @@ static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) { + (void)opaque; int ret; ret = ferror((FILE *)stream); return ret; diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h index 4011e9cabb..e9e5899852 100644 --- a/thirdparty/minizip/ioapi.h +++ b/thirdparty/minizip/ioapi.h @@ -107,8 +107,7 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; typedef uint64_t ZPOS64_T; #else -/* Maximum unsigned 32-bit value used as placeholder for zip64 */ -#define MAXU32 0xffffffff + #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 ZPOS64_T; @@ -118,7 +117,10 @@ typedef unsigned long long int ZPOS64_T; #endif #endif - +/* Maximum unsigned 32-bit value used as placeholder for zip64 */ +#ifndef MAXU32 +#define MAXU32 (0xffffffff) +#endif #ifdef __cplusplus extern "C" { diff --git a/thirdparty/minizip/patches/godot-seek.patch b/thirdparty/minizip/patches/godot-seek.patch new file mode 100644 index 0000000000..24838c252a --- /dev/null +++ b/thirdparty/minizip/patches/godot-seek.patch @@ -0,0 +1,294 @@ +diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c +index d666e5a228..db4c33b4b9 100644 +--- a/thirdparty/minizip/ioapi.c ++++ b/thirdparty/minizip/ioapi.c +@@ -80,8 +80,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef + p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; + p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; + p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; ++ /* GODOT start */ ++ p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem; ++ p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem; ++ /* GODOT end */ + } + ++/* GODOT start */ ++/* ++// GODOT end + + + static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); +@@ -255,3 +262,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; + } ++// GODOT start ++*/ ++/* GODOT end */ +diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h +index 114bfab762..2f24a5b6a0 100644 +--- a/thirdparty/minizip/ioapi.h ++++ b/thirdparty/minizip/ioapi.h +@@ -155,6 +155,10 @@ typedef struct zlib_filefunc_def_s + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; ++ /* GODOT start */ ++ alloc_func alloc_mem; ++ free_func free_mem; ++ /* GODOT end */ + } zlib_filefunc_def; + + typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); +@@ -171,6 +175,10 @@ typedef struct zlib_filefunc64_def_s + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; ++ /* GODOT start */ ++ alloc_func alloc_mem; ++ free_func free_mem; ++ /* GODOT end */ + } zlib_filefunc64_def; + + void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); +diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c +index 5e12e47474..3b191e827c 100644 +--- a/thirdparty/minizip/unzip.c ++++ b/thirdparty/minizip/unzip.c +@@ -157,6 +157,9 @@ typedef struct + uLong compression_method; /* compression method (0==store) */ + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + int raw; ++ /* GODOT start */ ++ int extra_size; ++ /* GODOT end */ + } file_in_zip64_read_info_s; + + +@@ -606,9 +609,10 @@ local unzFile unzOpenInternal (const void *path, + us.z_filefunc.zseek32_file = NULL; + us.z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) +- fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); +- else +- us.z_filefunc = *pzlib_filefunc64_32_def; ++ /* GODOT start */ ++ return NULL; // standard i/o not supported ++ us.z_filefunc = *pzlib_filefunc64_32_def; ++ /* GODOT end */ + us.is64bitOpenFunction = is64bitOpenFunction; + + +@@ -800,6 +804,18 @@ extern unzFile ZEXPORT unzOpen64 (const void *path) + return unzOpenInternal(path, NULL, 1); + } + ++/* GODOT start */ ++extern void* unzGetOpaque(unzFile file) { ++ ++ unz64_s* s; ++ if (file==NULL) ++ return NULL; ++ s=(unz64_s*)file; ++ ++ return s->z_filefunc.zfile_func64.opaque; ++}; ++/* GODOT end */ ++ + /* + Close a ZipFile opened with unzOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), +@@ -1018,10 +1034,23 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, + + if (lSeek!=0) + { ++ /* GODOT start */ ++ if (lSeek<0) { ++ // WORKAROUND for backwards seeking ++ ZPOS64_T pos = ZTELL64(s->z_filefunc, s->filestream); ++ if (ZSEEK64(s->z_filefunc, s->filestream,pos+(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_SET)==0) ++ lSeek=0; ++ else ++ err=UNZ_ERRNO; ++ } else { ++ /* GODOT end */ + if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; ++ /* GODOT start */ ++ } ++ /* GODOT end */ + } + + while(acc < file_info.size_file_extra) +@@ -1575,8 +1604,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, + } + else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) + { +- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; +- pfile_in_zip_read_info->stream.zfree = (free_func)0; ++ /* GODOT start */ ++ pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem; ++ pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem; ++ /* GODOT end */ + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = 0; + pfile_in_zip_read_info->stream.avail_in = 0; +@@ -1608,6 +1639,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; ++ /* GODOT start */ ++ pfile_in_zip_read_info->extra_size = iSizeVar; ++ /* GODOT end */ + + s->pfile_in_zip_read = pfile_in_zip_read_info; + s->encrypted = 0; +@@ -1638,6 +1672,85 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, + return UNZ_OK; + } + ++/* GODOT start */ ++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) { ++ ++ unz64_s* s; ++ file_in_zip64_read_info_s* pfile_in_zip_read_info; ++ if (file==NULL) ++ return UNZ_PARAMERROR; ++ s=(unz64_s*)file; ++ pfile_in_zip_read_info=s->pfile_in_zip_read; ++ ++ if (pfile_in_zip_read_info==NULL) ++ return UNZ_PARAMERROR; ++ ++ if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip ++ return UNZ_INTERNALERROR; ++ } ++ ++ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) { ++ ++ pfile_in_zip_read_info->rest_read_compressed = ++ s->cur_file_info.compressed_size - pos; ++ pfile_in_zip_read_info->rest_read_uncompressed = ++ s->cur_file_info.uncompressed_size - pos; ++ ++ pfile_in_zip_read_info->pos_in_zipfile = ++ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + ++ pfile_in_zip_read_info->extra_size + pos; ++ ++ pfile_in_zip_read_info->stream.avail_in = (uInt)0; ++ pfile_in_zip_read_info->stream.total_out = pos; ++ ++ return ZSEEK64(pfile_in_zip_read_info->z_filefunc, ++ pfile_in_zip_read_info->filestream, ++ pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile, ++ ZLIB_FILEFUNC_SEEK_SET); ++ ++ } else { // gzip ++ ++ if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind ++ ++ pfile_in_zip_read_info->rest_read_compressed = ++ s->cur_file_info.compressed_size ; ++ pfile_in_zip_read_info->rest_read_uncompressed = ++ s->cur_file_info.uncompressed_size ; ++ ++ pfile_in_zip_read_info->pos_in_zipfile = ++ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + ++ pfile_in_zip_read_info->extra_size; ++ ++ (void)inflateReset(&pfile_in_zip_read_info->stream); ++ ++ pfile_in_zip_read_info->stream.avail_in = (uInt)0; ++ pfile_in_zip_read_info->stream.total_out = 0; ++ pfile_in_zip_read_info->stream.next_in = 0; ++ } ++ ++ // not sure where to read, so read on the stack ++ { ++ char buf[512]; ++ int to_read = pos - pfile_in_zip_read_info->stream.total_out; ++ while (to_read) { ++ ++ int len = to_read > sizeof(buf)?sizeof(buf):to_read; ++ int read = unzReadCurrentFile(file, buf, len); ++ if (read < 0) { ++ return read; ++ } ++ to_read -= read; ++ if (read == UNZ_EOF) { ++ return pos; ++ } ++ } ++ } ++ } ++ ++ return pos; ++} ++/* GODOT end */ ++ + extern int ZEXPORT unzOpenCurrentFile (unzFile file) + { + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); +diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h +index 6f95e94d75..71a7d89692 100644 +--- a/thirdparty/minizip/unzip.h ++++ b/thirdparty/minizip/unzip.h +@@ -202,6 +202,10 @@ extern int ZEXPORT unzClose OF((unzFile file)); + these files MUST be closed with unzCloseCurrentFile before call unzClose. + return UNZ_OK if there is no problem. */ + ++/* GODOT start */ ++extern void* unzGetOpaque(unzFile file); ++/* GODOT end */ ++ + extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); + +@@ -390,6 +394,13 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + (UNZ_ERRNO for IO error, or zLib error for uncompress error) + */ + ++/* GODOT start */ ++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos); ++/* ++ Seek to position in uncompressed data ++*/ ++/* GODOT end */ ++ + extern z_off_t ZEXPORT unztell OF((unzFile file)); + + extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); +diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c +index 4e611e1163..6d1c26d9f8 100644 +--- a/thirdparty/minizip/zip.c ++++ b/thirdparty/minizip/zip.c +@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl + + ziinit.z_filefunc.zseek32_file = NULL; + ziinit.z_filefunc.ztell32_file = NULL; +- if (pzlib_filefunc64_32_def==NULL) +- fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); +- else ++ /* GODOT start */ ++ if (pzlib_filefunc64_32_def==NULL) { ++ //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); ++ } else ++ /* GODOT end */ + ziinit.z_filefunc = *pzlib_filefunc64_32_def; + + ziinit.filestream = ZOPEN64(ziinit.z_filefunc, +@@ -1211,8 +1213,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, + { + if(zi->ci.method == Z_DEFLATED) + { +- zi->ci.stream.zalloc = (alloc_func)0; +- zi->ci.stream.zfree = (free_func)0; ++ /* GODOT start */ ++ zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem; ++ zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem; ++ /* GODOT end */ + zi->ci.stream.opaque = (voidpf)0; + + if (windowBits>0) diff --git a/thirdparty/minizip/patches/unbreak-gentoo.patch b/thirdparty/minizip/patches/unbreak-gentoo.patch new file mode 100644 index 0000000000..9292e32ac6 --- /dev/null +++ b/thirdparty/minizip/patches/unbreak-gentoo.patch @@ -0,0 +1,27 @@ +diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h +index f25ab6464..6043d34ce 100644 +--- a/thirdparty/minizip/ioapi.h ++++ b/thirdparty/minizip/ioapi.h +@@ -44,6 +44,22 @@ + #include + #include "zlib.h" + ++/* GODOT start */ ++/* Mighty Gentoo saves the day by breaking the API of their zlib.h, ++ * removing this definition of OF(args) for no practical reason ++ * worth breaking compatibility with all projects that embed minizip ++ * while trying not to diverge too much from upstream zlib. ++ * Cf. https://github.com/godotengine/godot/issues/10539 ++ * ++ * "By and large, this is good open source behaviour, and fits with ++ * the gentoo _don't fuck with upstream's releases_ philosophy" ++ * -- Gentoo philosopher ++ */ ++#ifndef OF /* function prototypes */ ++ #define OF(args) args ++#endif ++/* GODOT end */ ++ + #if defined(USE_FILE32API) + #define fopen64 fopen + #define ftello64 ftell diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c index 31f8a5ff47..3b191e827c 100644 --- a/thirdparty/minizip/unzip.c +++ b/thirdparty/minizip/unzip.c @@ -458,7 +458,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } @@ -526,7 +526,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } @@ -869,13 +869,13 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) { ZPOS64_T uDate; uDate = (ZPOS64_T)(ulDosDate>>16); - ptm->tm_mday = (uInt)(uDate&0x1f) ; - ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + ptm->tm_mday = (int)(uDate&0x1f) ; + ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; - ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; + ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ; } /* @@ -1009,7 +1009,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, if (lSeek!=0) { - if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; @@ -1037,17 +1037,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, /* GODOT start */ if (lSeek<0) { // WORKAROUND for backwards seeking - z_off_t pos = ZTELL64(s->z_filefunc, s->filestream); - if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0) + ZPOS64_T pos = ZTELL64(s->z_filefunc, s->filestream); + if (ZSEEK64(s->z_filefunc, s->filestream,pos+(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_SET)==0) lSeek=0; else err=UNZ_ERRNO; } else { - if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + /* GODOT end */ + if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + /* GODOT start */ } + /* GODOT end */ } while(acc < file_info.size_file_extra) @@ -1116,7 +1119,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, if (lSeek!=0) { - if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; @@ -1684,7 +1687,7 @@ extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) { if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip return UNZ_INTERNALERROR; - }; + } if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) { @@ -1723,7 +1726,7 @@ extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) { pfile_in_zip_read_info->stream.avail_in = (uInt)0; pfile_in_zip_read_info->stream.total_out = 0; pfile_in_zip_read_info->stream.next_in = 0; - }; + } // not sure where to read, so read on the stack { @@ -1735,17 +1738,17 @@ extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) { int read = unzReadCurrentFile(file, buf, len); if (read < 0) { return read; - }; + } to_read -= read; if (read == UNZ_EOF) { return pos; - }; - }; - }; - }; + } + } + } + } return pos; -}; +} /* GODOT end */ extern int ZEXPORT unzOpenCurrentFile (unzFile file) @@ -1877,7 +1880,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) if ((pfile_in_zip_read_info->stream.avail_in == 0) && (pfile_in_zip_read_info->rest_read_compressed == 0)) - return (iRead==0) ? UNZ_EOF : iRead; + return (iRead==0) ? UNZ_EOF : (int)iRead; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) @@ -1967,6 +1970,9 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) err = Z_DATA_ERROR; uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + /* Detect overflow, because z_stream.total_out is uLong (32 bits) */ + if (uTotalOutAftertotal_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; @@ -1981,14 +1987,14 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; + return (iRead==0) ? UNZ_EOF : (int)iRead; if (err!=Z_OK) break; } } if (err==Z_OK) - return iRead; + return (int)iRead; return err; } diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h index bab1cb939f..71a7d89692 100644 --- a/thirdparty/minizip/unzip.h +++ b/thirdparty/minizip/unzip.h @@ -83,12 +83,12 @@ typedef voidp unzFile; /* tm_unz contain date/time info */ typedef struct tm_unz_s { - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c index 2936e2b5d9..6d1c26d9f8 100644 --- a/thirdparty/minizip/zip.c +++ b/thirdparty/minizip/zip.c @@ -158,7 +158,7 @@ typedef struct #ifndef NOCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ const z_crc_t* pcrc_32_tab; - int crypt_header_size; + unsigned crypt_header_size; #endif } curfile64_info; @@ -301,7 +301,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, } } - if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte) return ZIP_ERRNO; else return ZIP_OK; @@ -337,8 +337,8 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) else if (year>=80) year-=80; return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); + (uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) | + (((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); } @@ -522,12 +522,12 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } - if (uPosFound!=0) - break; + if (uPosFound!=0) + break; } TRYFREE(buf); return uPosFound; @@ -586,7 +586,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib // Signature "0x07064b50" Zip64 end of central directory locater if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) { - uPosFound = uReadPos+i; + uPosFound = uReadPos+(unsigned)i; break; } } @@ -637,7 +637,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib return relativeOffset; } -int LoadCentralDirectoryRecord(zip64_internal* pziinit) +local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { int err=ZIP_OK; ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ @@ -957,7 +957,7 @@ extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) return zipOpen3(pathname,append,NULL,NULL); } -int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) +local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) { /* write the local header */ int err; @@ -1036,8 +1036,8 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); @@ -1520,7 +1520,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s zip64_internal* zi; ZPOS64_T compressed_size; uLong invalidValue = 0xffffffff; - short datasize = 0; + unsigned datasize = 0; int err=ZIP_OK; if (file == NULL) @@ -1756,7 +1756,7 @@ extern int ZEXPORT zipCloseFileInZip (zipFile file) return zipCloseFileInZipRaw (file,0,0); } -int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) +local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { int err = ZIP_OK; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; @@ -1778,7 +1778,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo return err; } -int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; @@ -1817,7 +1817,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra } return err; } -int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { int err = ZIP_OK; @@ -1865,7 +1865,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, return err; } -int Write_GlobalComment(zip64_internal* zi, const char* global_comment) +local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) { int err = ZIP_OK; uInt size_global_comment = 0; @@ -1966,7 +1966,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe if(pData == NULL || *dataLen < 4) return ZIP_PARAMERROR; - pNewHeader = (char*)ALLOC(*dataLen); + pNewHeader = (char*)ALLOC((unsigned)*dataLen); pTmp = pNewHeader; while(p < (pData + *dataLen)) diff --git a/thirdparty/minizip/zip.h b/thirdparty/minizip/zip.h index 8aaebb6234..7e4509d77b 100644 --- a/thirdparty/minizip/zip.h +++ b/thirdparty/minizip/zip.h @@ -88,12 +88,12 @@ typedef voidp zipFile; /* tm_zip contain date/time info */ typedef struct tm_zip_s { - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years - [1980..2044] */ } tm_zip; typedef struct @@ -144,6 +144,11 @@ extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def)); +extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); + extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, -- cgit v1.2.3