From 5234a0531a6ae91d4009e4deaf966c8c432aed4c Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 6 Feb 2018 03:06:53 +0000 Subject: zziplib 0.13.68 git-svn-id: svn://tug.org/texlive/trunk@46553 c570f23f-e606-0410-a88d-b1316a301751 --- .../libs/zziplib/zziplib-src/zzip/Makefile.am | 2 +- .../libs/zziplib/zziplib-src/zzip/Makefile.in | 2 +- .../source/libs/zziplib/zziplib-src/zzip/__debug.h | 79 ++++++++------ .../source/libs/zziplib/zziplib-src/zzip/__errno.h | 11 ++ .../libs/zziplib/zziplib-src/zzip/__fnmatch.h | 12 +- .../source/libs/zziplib/zziplib-src/zzip/__hints.h | 2 +- .../source/libs/zziplib/zziplib-src/zzip/__mkdir.h | 12 ++ .../libs/zziplib/zziplib-src/zzip/__string.h | 67 ++++++++++++ Build/source/libs/zziplib/zziplib-src/zzip/file.c | 2 +- .../source/libs/zziplib/zziplib-src/zzip/fseeko.c | 15 +-- .../source/libs/zziplib/zziplib-src/zzip/fseeko.h | 30 +++++ Build/source/libs/zziplib/zziplib-src/zzip/info.c | 46 ++++---- Build/source/libs/zziplib/zziplib-src/zzip/lib.h | 2 +- .../source/libs/zziplib/zziplib-src/zzip/memdisk.c | 121 +++++++++++++-------- .../source/libs/zziplib/zziplib-src/zzip/memdisk.h | 19 ++-- .../source/libs/zziplib/zziplib-src/zzip/mmapped.c | 121 +++++++-------------- .../source/libs/zziplib/zziplib-src/zzip/mmapped.h | 2 +- Build/source/libs/zziplib/zziplib-src/zzip/write.c | 16 +-- Build/source/libs/zziplib/zziplib-src/zzip/zip.c | 14 ++- .../zziplib/zziplib-src/zzip/zzip-zlib-config.pc | 8 ++ Build/source/libs/zziplib/zziplib-src/zzip/zzip.h | 2 +- .../libs/zziplib/zziplib-src/zzip/zzipfseeko.pc | 18 +++ .../libs/zziplib/zziplib-src/zzip/zziplib.pc | 18 +++ .../libs/zziplib/zziplib-src/zzip/zzipmmapped.pc | 18 +++ 24 files changed, 411 insertions(+), 228 deletions(-) create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/__errno.h create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/__mkdir.h create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/__string.h create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/zzip-zlib-config.pc create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/zzipfseeko.pc create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/zziplib.pc create mode 100644 Build/source/libs/zziplib/zziplib-src/zzip/zzipmmapped.pc (limited to 'Build/source/libs/zziplib/zziplib-src/zzip') diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.am b/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.am index 0319cc80fa5..5f333fbea61 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.am +++ b/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.am @@ -8,7 +8,7 @@ zzipdir = ${includedir}/zzip zzip_HEADERS = $(libzzip_la_headers) \ $(libzzipmmapped_la_headers) \ $(libzzipfseeko_la_headers) -noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h +noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h __string.h __mkdir.h __errno.h # VERSION_INFO=@VERSION_INFO@ RELEASE_INFO=@RELEASE_INFO@ diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.in b/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.in index 03ee59755cf..8a835ab1bc7 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.in +++ b/Build/source/libs/zziplib/zziplib-src/zzip/Makefile.in @@ -397,7 +397,7 @@ zzip_HEADERS = $(libzzip_la_headers) \ $(libzzipmmapped_la_headers) \ $(libzzipfseeko_la_headers) -noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h +noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h __string.h __mkdir.h __errno.h # libzzip_la_SOURCES = \ zip.c \ diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__debug.h b/Build/source/libs/zziplib/zziplib-src/zzip/__debug.h index 13c7d895443..b79e5587f64 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/__debug.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__debug.h @@ -8,61 +8,68 @@ #ifdef DEBUG #include -#define DBG1(X1) ZZIP_FOR1 { \ +#define MSG1(X1) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ); } ZZIP_END1 -#define DBG2(X1,X2) ZZIP_FOR1 { \ +#define MSG2(X1,X2) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ,X2);} ZZIP_END1 -#define DBG3(X1,X2,X3) ZZIP_FOR1 { \ +#define MSG3(X1,X2,X3) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ,X2,X3); } ZZIP_END1 -#define DBG4(X1,X2,X3,X4) ZZIP_FOR1 { \ +#define MSG4(X1,X2,X3,X4) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ,X2,X3,X4); } ZZIP_END1 -#define DBG5(X1,X2,X3,X4,X5) ZZIP_FOR1 { \ +#define MSG5(X1,X2,X3,X4,X5) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ,X2,X3,X4,X5); } ZZIP_END1 -#define DBG6(X1,X2,X3,X4,X5,X6) ZZIP_FOR1 { \ +#define MSG6(X1,X2,X3,X4,X5,X6) ZZIP_FOR1 { \ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \ ,X2,X3,X4,X5,X6); } ZZIP_END1 #else -#define DBG1(X1) {} -#define DBG2(X1,X2) {} -#define DBG3(X1,X2,X3) {} -#define DBG4(X1,X2,X3,X4) {} -#define DBG5(X1,X2,X3,X4,X5) {} -#define DBG6(X1,X2,X3,X4,X5,X6) {} +#define MSG1(X1) {} +#define MSG2(X1,X2) {} +#define MSG3(X1,X2,X3) {} +#define MSG4(X1,X2,X3,X4) {} +#define MSG5(X1,X2,X3,X4,X5) {} +#define MSG6(X1,X2,X3,X4,X5,X6) {} #endif -#define HINT1(X1) DBG1("HINT: " X1) -#define HINT2(X1,X2) DBG2("HINT: " X1,X2) -#define HINT3(X1,X2,X3) DBG3("HINT: " X1,X2,X3) -#define HINT4(X1,X2,X3,X4) DBG4("HINT: " X1,X2,X3,X4) -#define HINT5(X1,X2,X3,X4,X5) DBG5("HINT: " X1,X2,X3,X4,X5) -#define HINT6(X1,X2,X3,X4,X5,X6) DBG6("HINT: " X1,X2,X3,X4,X5,X6) +#define DBG1(X1) MSG1("DEBUG: " X1) +#define DBG2(X1,X2) MSG2("DEBUG: " X1,X2) +#define DBG3(X1,X2,X3) MSG3("DEBUG: " X1,X2,X3) +#define DBG4(X1,X2,X3,X4) MSG4("DEBUG: " X1,X2,X3,X4) +#define DBG5(X1,X2,X3,X4,X5) MSG5("DEBUG: " X1,X2,X3,X4,X5) +#define DBG6(X1,X2,X3,X4,X5,X6) MSG6("DEBUG: " X1,X2,X3,X4,X5,X6) -#define NOTE1(X1) DBG1("NOTE: " X1) -#define NOTE2(X1,X2) DBG2("NOTE: " X1,X2) -#define NOTE3(X1,X2,X3) DBG3("NOTE: " X1,X2,X3) -#define NOTE4(X1,X2,X3,X4) DBG4("NOTE: " X1,X2,X3,X4) -#define NOTE5(X1,X2,X3,X4,X5) DBG5("NOTE: " X1,X2,X3,X4,X5) -#define NOTE6(X1,X2,X3,X4,X5,X6) DBG6("NOTE: " X1,X2,X3,X4,X5,X6) +#define HINT1(X1) MSG1("HINT: " X1) +#define HINT2(X1,X2) MSG2("HINT: " X1,X2) +#define HINT3(X1,X2,X3) MSG3("HINT: " X1,X2,X3) +#define HINT4(X1,X2,X3,X4) MSG4("HINT: " X1,X2,X3,X4) +#define HINT5(X1,X2,X3,X4,X5) MSG5("HINT: " X1,X2,X3,X4,X5) +#define HINT6(X1,X2,X3,X4,X5,X6) MSG6("HINT: " X1,X2,X3,X4,X5,X6) -#define WARN1(X1) DBG1("WARN: " X1) -#define WARN2(X1,X2) DBG2("WARN: " X1,X2) -#define WARN3(X1,X2,X3) DBG3("WARN: " X1,X2,X3) -#define WARN4(X1,X2,X3,X4) DBG4("WARN: " X1,X2,X3,X4) -#define WARN5(X1,X2,X3,X4,X5) DBG5("WARN: " X1,X2,X3,X4,X5) -#define WARN6(X1,X2,X3,X4,X5,X6) DBG6("WARN: " X1,X2,X3,X4,X5,X6) +#define NOTE1(X1) MSG1("NOTE: " X1) +#define NOTE2(X1,X2) MSG2("NOTE: " X1,X2) +#define NOTE3(X1,X2,X3) MSG3("NOTE: " X1,X2,X3) +#define NOTE4(X1,X2,X3,X4) MSG4("NOTE: " X1,X2,X3,X4) +#define NOTE5(X1,X2,X3,X4,X5) MSG5("NOTE: " X1,X2,X3,X4,X5) +#define NOTE6(X1,X2,X3,X4,X5,X6) MSG6("NOTE: " X1,X2,X3,X4,X5,X6) -#define FAIL1(X1) DBG1("FAIL: " X1) -#define FAIL2(X1,X2) DBG2("FAIL: " X1,X2) -#define FAIL3(X1,X2,X3) DBG3("FAIL: " X1,X2,X3) -#define FAIL4(X1,X2,X3,X4) DBG4("FAIL: " X1,X2,X3,X4) -#define FAIL5(X1,X2,X3,X4,X5) DBG5("FAIL: " X1,X2,X3,X4,X5) -#define FAIL6(X1,X2,X3,X4,X5,X6) DBG6("FAIL: " X1,X2,X3,X4,X5,X6) +#define WARN1(X1) MSG1("WARN: " X1) +#define WARN2(X1,X2) MSG2("WARN: " X1,X2) +#define WARN3(X1,X2,X3) MSG3("WARN: " X1,X2,X3) +#define WARN4(X1,X2,X3,X4) MSG4("WARN: " X1,X2,X3,X4) +#define WARN5(X1,X2,X3,X4,X5) MSG5("WARN: " X1,X2,X3,X4,X5) +#define WARN6(X1,X2,X3,X4,X5,X6) MSG6("WARN: " X1,X2,X3,X4,X5,X6) + +#define FAIL1(X1) MSG1("FAIL: " X1) +#define FAIL2(X1,X2) MSG2("FAIL: " X1,X2) +#define FAIL3(X1,X2,X3) MSG3("FAIL: " X1,X2,X3) +#define FAIL4(X1,X2,X3,X4) MSG4("FAIL: " X1,X2,X3,X4) +#define FAIL5(X1,X2,X3,X4,X5) MSG5("FAIL: " X1,X2,X3,X4,X5) +#define FAIL6(X1,X2,X3,X4,X5,X6) MSG6("FAIL: " X1,X2,X3,X4,X5,X6) diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__errno.h b/Build/source/libs/zziplib/zziplib-src/zzip/__errno.h new file mode 100644 index 00000000000..d66ac3f7154 --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__errno.h @@ -0,0 +1,11 @@ +#ifndef __ZZIP_INTERNAL_ERRNO_H +#define __ZZIP_INTERNAL_ERRNO_H + +#include + +/* Mingw cross compile fix */ +#ifndef EBADMSG +#define EBADMSG 74 +#endif + +#endif diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__fnmatch.h b/Build/source/libs/zziplib/zziplib-src/zzip/__fnmatch.h index 340dbaa2c8c..59cea887682 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/__fnmatch.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__fnmatch.h @@ -13,18 +13,14 @@ #ifdef ZZIP_HAVE_FNMATCH_H #define _zzip_fnmatch fnmatch # ifdef FNM_CASEFOLD -# define _zzip_fnmatch_CASEFOLD FNM_CASEFOLD +# define _zzip_FNM_CASEFOLD FNM_CASEFOLD # else -# define _zzip_fnmatch_CASEFOLD 0 +# define _zzip_FNM_CASEFOLD 0 # endif #else -# define _zzip_fnmatch_CASEFOLD 0 +# define _zzip_FNM_CASEFOLD 0 /* if your system does not have fnmatch, we fall back to strcmp: */ -static int _zzip_fnmatch(char* pattern, char* string, int flags) -{ - fprintf (stderr, ""); - return strcmp (pattern, string); -} +#define _zzip_fnmatch(x,y,z) strcmp ((x),(y)) #endif #endif diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__hints.h b/Build/source/libs/zziplib/zziplib-src/zzip/__hints.h index d071c4ebd7f..1d2eef0b455 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/__hints.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__hints.h @@ -94,7 +94,7 @@ # endif #endif -/* resolve references to this function during pre-linking the libary */ +/* resolve references to this function during pre-linking the library */ #ifndef ZZIP_GNUC_LIB_PROTECTED # if ZZIP_GNUC_ATLEAST(3,1) # define ZZIP_GNUC_LIB_PROTECTED __attribute__((visiblity("protected"))) diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__mkdir.h b/Build/source/libs/zziplib/zziplib-src/zzip/__mkdir.h new file mode 100644 index 00000000000..c1bffa44454 --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__mkdir.h @@ -0,0 +1,12 @@ +#ifndef __ZZIP_INTERNAL_MKDIR_H +#define __ZZIP_INTERNAL_MKDIR_H + +#include + +# ifdef ZZIP_HAVE_DIRECT_H +# define _zzip_mkdir(a,b) mkdir(a) +# else +# define _zzip_mkdir mkdir +# endif + +#endif diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__string.h b/Build/source/libs/zziplib/zziplib-src/zzip/__string.h new file mode 100644 index 00000000000..351b0c14162 --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__string.h @@ -0,0 +1,67 @@ +#ifndef __ZZIP_INTERNAL_STRING_H +#define __ZZIP_INTERNAL_STRING_H + +#ifdef __linux__ +#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_strndup_gnu_specific_ +#endif + +#include + +#if defined ZZIP_HAVE_STRING_H +#include +#elif defined ZZIP_HAVE_STRINGS_H +#include +#endif + + +#if defined ZZIP_HAVE_STRNDUP || defined strndup +#define _zzip_strndup strndup +#else + +/* if your system does not have strndup: */ +zzip__new__ static char * +_zzip_strndup(char const *p, size_t maxlen) +{ + if (p == NULL) + { + return p; + } else + { + size_t len = strnlen(p, maxlen); + char* r = malloc(len + 1); + if (r == NULL) + return NULL; /* errno = ENOMEM */ + r[len] = '\0'; + return memcpy(r, p, len); + } +} +#endif + +#if defined ZZIP_HAVE_STRCASECMP || defined strcasecmp +#define _zzip_strcasecmp strcasecmp +#else + +/* if your system does not have strcasecmp: */ +static int +_zzip_strcasecmp(char *__zzip_restrict a, char *_zzip_restrict b) +{ + if (! a) + return (b) ? 1 : 0; + if (! b) + return -1; + while (1) + { + int v = tolower(*a) - tolower(*b); + if (v) + return v; + if (! *a) + return 1; + if (! *b) + return -1; + a++; + b++; + } +} +#endif + +#endif diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/file.c b/Build/source/libs/zziplib/zziplib-src/zzip/file.c index f7c5fa89725..fb91d9815d0 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/file.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/file.c @@ -577,7 +577,7 @@ zzip_fopen(zzip_char_t * filename, zzip_char_t * mode) * Per default, the old file stream is closed and only the internal * structures associated with it are kept. These internal structures * may be reused for the return value, and this is a lot quicker when - * the filename matches a zipped file that is incidently in the very + * the filename matches a zipped file that is incidentally in the very * same zip arch as the old filename wrapped in the stream struct. * * That's simply because the zip arch's central directory does not diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.c b/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.c index ba19b436fb0..33794927606 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -78,10 +79,10 @@ #define PAGESIZE 8192 #ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) +#define debug1(msg) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__); } while(0) +#define debug2(msg, arg1) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1); } while(0) +#define debug3(msg, arg1, arg2) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1, arg2); } while(0) +#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) #else #define debug1(msg) #define debug2(msg, arg1) @@ -97,7 +98,7 @@ * This functions read the correspoding struct zzip_file_header from * the zip disk of the given "entry". The returned off_t points to the * end of the file_header where the current fseek pointer has stopped. - * This is used to immediatly parse out any filename/extras block following + * This is used to immediately parse out any filename/extras block following * the file_header. * * Returns zero on error. (errno = EINVAL|EBADMSG|EBADF|EIO) @@ -319,7 +320,7 @@ zzip_entry_findfirst(FILE * disk) } /* we read out chunks of 8 KiB in the hope to match disk granularity */ ___ zzip_off_t pagesize = PAGESIZE; /* getpagesize() */ - ___ ZZIP_ENTRY *entry = malloc(sizeof(*entry)); + ___ ZZIP_ENTRY *entry = calloc(1, sizeof(*entry)); if (! entry) goto error0; /* ENOMEM */ ___ unsigned char *buffer = malloc(pagesize); @@ -808,7 +809,7 @@ zzip_entry_fread(void *ptr, zzip_size_t sized, zzip_size_t nmemb, file->entry->diskfile); file->zlib.next_in = file->buffer; file->dataoff += file->zlib.avail_in; - debug2("remaing compressed fread %lli", (long long) file->zlib.avail_in); + debug2("remaining compressed fread %lli", (long long) file->zlib.avail_in); } if (! file->zlib.avail_in) { diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.h b/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.h index c790cf6a3af..96faa011a4a 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/fseeko.h @@ -99,6 +99,7 @@ struct zzip_entry : public struct zzip_disk_entry zzip_off_t zz_offset; /* or zip64 extension block */ int zz_diskstart; }; +# define zzip_entry_d(_p) (_p) # else struct zzip_entry /* : struct zzip_disk_entry */ { @@ -113,9 +114,38 @@ struct zzip_entry /* : struct zzip_disk_entry */ zzip_off_t zz_offset; /* or zip64 extension block */ int zz_diskstart; }; +# define zzip_entry_d(_p) (&(_p)->head) # endif /* __cplusplus */ # endif /* _ZZIP_MEM_ENTRY_PRIVATE */ +#ifdef _ZZIP_ENTRY_STRUCT +/* zzip_entry is-a zip_disk_entry => fetch.h */ +#define zzip_entry_csize(__p) ((zzip_size_t) \ + zzip_disk_entry_get_csize(zzip_entry_d(__p))) +#define zzip_entry_usize(__p) ((zzip_size_t) \ + zzip_disk_entry_get_usize(zzip_entry_d(__p))) +#define zzip_entry_compr(__p) ( \ + zzip_disk_entry_get_compr(zzip_entry_d(__p))) +#define zzip_entry_flags(__p) ( \ + zzip_disk_entry_get_flags(zzip_entry_d(__p))) +#define zzip_entry_namlen(__p) ((zzip_size_t) \ + zzip_disk_entry_get_namlen(zzip_entry_d(__p))) +#define zzip_entry_extras(__p) ((zzip_size_t) \ + zzip_disk_entry_get_extras(zzip_entry_d(__p))) +#define zzip_entry_comment(__p) ((zzip_size_t) \ + zzip_disk_entry_get_comment(zzip_entry_d(__p))) +#define zzip_entry_diskstart(__p) ((int) \ + zzip_disk_entry_get_diskstart(zzip_entry_d(__p))) +#define zzip_entry_filetype(__p) ((int) \ + zzip_disk_entry_get_filetype(zzip_entry_d(__p))) +#define zzip_entry_filemode(__p) ((int) \ + zzip_disk_entry_get_filemode(zzip_entry_d(__p))) +#define zzip_entry_fileoffset(__p) ((zzip_off_t) \ + zzip_disk_entry_get_offset(zzip_entry_d(__p))) +#define zzip_entry_sizeof_tail(__p) ((zzip_size_t) \ + zzip_disk_entry_sizeof_tails(zzip_entry_d(__p))) +#endif + #ifdef __cplusplus extern "C" { } diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/info.c b/Build/source/libs/zziplib/zziplib-src/zzip/info.c index 70d393deff8..ab226bc9a20 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/info.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/info.c @@ -58,6 +58,10 @@ zzip_dirfd(ZZIP_DIR * dir) return dir->fd; } +static const char* comprlevel[] = { + "stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4", + "impl:N", "toknze", "defl:N", "defl:B", "impl:B" }; + /** * return static const string of the known compression methods, * otherwise just "zipped" is returned @@ -65,46 +69,34 @@ zzip_dirfd(ZZIP_DIR * dir) zzip_char_t * zzip_compr_str(int compr) { - switch (compr) + if (0 <= compr && compr < sizeof(comprlevel)) + { + return comprlevel[compr]; + } else if (0 < compr && compr < 256) + { + return "zipped"; + } else { - /* *INDENT-OFF* */ - case ZZIP_IS_STORED: return "stored"; - case ZZIP_IS_SHRUNK: return "shrunk"; - case ZZIP_IS_REDUCEDx1: - case ZZIP_IS_REDUCEDx2: - case ZZIP_IS_REDUCEDx3: - case ZZIP_IS_REDUCEDx4: return "reduced"; - case ZZIP_IS_IMPLODED: return "imploded"; - case ZZIP_IS_TOKENIZED: return "tokenized"; - case ZZIP_IS_DEFLATED: return "deflated"; - case ZZIP_IS_DEFLATED_BETTER: return "deflatedX"; - case ZZIP_IS_IMPLODED_BETTER: return "implodedX"; - default: - if (0 < compr && compr < 256) return "zipped"; - else - { # ifdef S_ISDIR - if (S_ISDIR(compr)) return "directory"; + if (S_ISDIR(compr)) return "directory"; # endif # ifdef S_ISCHR - if (S_ISCHR(compr)) return "is/chr"; + if (S_ISCHR(compr)) return "is/chr"; # endif # ifdef S_ISBLK - if (S_ISBLK(compr)) return "is/blk"; + if (S_ISBLK(compr)) return "is/blk"; # endif # ifdef S_ISFIFO - if (S_ISFIFO(compr)) return "is/fifo"; + if (S_ISFIFO(compr)) return "is/fifo"; # endif # ifdef S_ISSOCK - if (S_ISSOCK(compr)) return "is/sock"; + if (S_ISSOCK(compr)) return "is/sock"; # endif # ifdef S_ISLNK - if (S_ISLNK(compr)) return "is/lnk"; + if (S_ISLNK(compr)) return "is/lnk"; # endif - return "special"; - } - /* *INDENT-ON* */ - } /*switch */ + return "special"; + } } /** => zzip_file_real diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/lib.h b/Build/source/libs/zziplib/zziplib-src/zzip/lib.h index 2d83f239b87..b09a1302829 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/lib.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/lib.h @@ -76,7 +76,7 @@ ZZIP_DIR* zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errorcode_p, zzip_strings_t* ext, const zzip_plugin_io_t io); -ZZIP_DIR* /*depracated*/ +ZZIP_DIR* /*deprecated*/ zzip_dir_alloc_ext_io (zzip_strings_t* ext, const zzip_plugin_io_t io); #ifdef __cplusplus diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.c b/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.c index 0b07da7db55..29b2a1b1b05 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.c @@ -33,16 +33,17 @@ #include #include #include +#include #define ___ { #define ____ } #define DEBUG 1 #ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) +#define debug1(msg) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__); } while(0) +#define debug2(msg, arg1) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1); } while(0) +#define debug3(msg, arg1, arg2) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1, arg2); } while(0) +#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "DEBUG: %s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) #else #define debug1(msg) #define debug2(msg, arg1) @@ -50,17 +51,6 @@ #define debug4(msg, arg1, arg2, arg3) #endif -static const char *error[] = { - "Ok", -# define _zzip_mem_disk_open_fail 1 - "zzip_mem_disk_open: zzip_disk_open did fail", -# define _zzip_mem_disk_fdopen_fail 2 - "zzip_mem_disk_fdopen: zzip_disk_mmap did fail" -# define _zzip_mem_disk_buffer_fail 3 - "zzip_mem_disk_buffer: zzip_disk_buffer did fail", - 0 -}; - #define ZZIP_EXTRA_zip64 0x0001 typedef struct _zzip_extra_zip64 { /* ZIP64 extended information extra field */ @@ -92,7 +82,10 @@ zzip_mem_disk_open(char *filename) { ZZIP_DISK *disk = zzip_disk_open(filename); if (! disk) - { perror(error[_zzip_mem_disk_open_fail]); return 0; } + { + debug2("can not open disk file %s", filename); + return 0; + } ___ ZZIP_MEM_DISK *dir = zzip_mem_disk_new(); if (zzip_mem_disk_load(dir, disk) == -1) { @@ -109,9 +102,15 @@ zzip_mem_disk_fdopen(int fd) { ZZIP_DISK *disk = zzip_disk_mmap(fd); if (! disk) - { perror(error[_zzip_mem_disk_fdopen_fail]); return 0; } + { + debug2("can not open disk fd %i", fd); + return 0; + } ___ ZZIP_MEM_DISK *dir = zzip_mem_disk_new(); - zzip_mem_disk_load(dir, disk); + if (zzip_mem_disk_load(dir, disk) == -1) + { + debug2("unable to load disk fd %s", fd); + } return dir; ____; } @@ -123,9 +122,15 @@ zzip_mem_disk_buffer(char *buffer, size_t buflen) { ZZIP_DISK *disk = zzip_disk_buffer(buffer, buflen); if (! disk) - { perror(error[_zzip_mem_disk_buffer_fail]); return 0; } + { + debug2("can not open disk buf %p", buffer); + return 0; + } ___ ZZIP_MEM_DISK *dir = zzip_mem_disk_new(); - zzip_mem_disk_load(dir, disk); + if (zzip_mem_disk_load(dir, disk) == -1) + { + debug2("unable to load disk buf %p", buffer); + } return dir; ____; } @@ -209,6 +214,14 @@ zzip_mem_entry_new(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry) item->zz_diskstart = zzip_disk_entry_get_diskstart(entry); item->zz_filetype = zzip_disk_entry_get_filetype(entry); + /* + * If the file is uncompressed, zz_csize and zz_usize should be the same + * If they are not, we cannot guarantee that either is correct, so ... + */ + if (item->zz_compr == ZZIP_IS_STORED && item->zz_csize != item->zz_usize) + { + goto error; + } /* zz_comment and zz_name are empty strings if not present on disk */ if (! item->zz_comment || ! item->zz_name) { @@ -221,34 +234,39 @@ zzip_mem_entry_new(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry) zzip_size_t /* */ ext2_len = zzip_file_header_get_extras(header); char *_zzip_restrict ext2_ptr = zzip_file_header_to_extras(header); - if (ext1_ptr + ext1_len >= disk->endbuf || - ext2_ptr + ext2_len >= disk->endbuf) + if (ext1_len > 0 && ext1_len <= 65535) { - errno = EBADMSG; /* format error CVE-2017-5978 */ - goto error; /* zzip_mem_entry_free(item); return 0; */ - } - - if (ext1_len) - { - void *mem = malloc(ext1_len); - if (! mem) goto error; /* errno = ENOMEM */ - item->zz_ext[1] = mem; - item->zz_extlen[1] = ext1_len; - memcpy(mem, ext1_ptr, ext1_len); + if (ext1_ptr + ext1_len >= disk->endbuf) + { + errno = EBADMSG; + goto error; /* zzip_mem_entry_free(item); return 0; */ + } else { + void *mem = malloc(ext1_len); + if (! mem) goto error; /* errno = ENOMEM */ + item->zz_ext[1] = mem; + item->zz_extlen[1] = ext1_len; + memcpy(mem, ext1_ptr, ext1_len); + } } - if (ext2_len) + if (ext2_len > 0 && ext2_len <= 65535) { - void *mem = malloc(ext2_len); - if (! mem) goto error; /* errno = ENOMEM */ - item->zz_ext[2] = mem; - item->zz_extlen[2] = ext2_len; - memcpy(mem, ext2_ptr, ext2_len); + if (ext2_ptr + ext2_len >= disk->endbuf) + { + errno = EBADMSG; + goto error; /* zzip_mem_entry_free(item); return 0; */ + } else { + void *mem = malloc(ext2_len); + if (! mem) goto error; /* errno = ENOMEM */ + item->zz_ext[2] = mem; + item->zz_extlen[2] = ext2_len; + memcpy(mem, ext2_ptr, ext2_len); + } } } { /* override sizes/offsets with zip64 values for largefile support */ zzip_extra_zip64 *block = (zzip_extra_zip64 *) - zzip_mem_entry_extra_block(item, ZZIP_EXTRA_zip64); + zzip_mem_entry_find_extra_block(item, ZZIP_EXTRA_zip64, sizeof(zzip_extra_zip64)); if (block) { item->zz_usize = ZZIP_GET64(block->z_usize); @@ -269,12 +287,26 @@ error: ____; } +/** => zzip_mem_entry_find_extra_block. + * + * Note that for this function only the block_header is asserted + * to be completely in memory, so the returned pointer should be checked. + */ +ZZIP_EXTRA_BLOCK * +zzip_mem_entry_extra_block(ZZIP_MEM_ENTRY * entry, short datatype) +{ + return zzip_mem_entry_find_extra_block(entry, datatype, 16); +} + /* find an extra block for the given datatype code. * The returned EXTRA_BLOCK is still in disk-encoding but * already a pointer into an allocated heap space block. + * + * The second argument of this function ensures that the + * complete datasize is in memory. */ ZZIP_EXTRA_BLOCK * -zzip_mem_entry_extra_block(ZZIP_MEM_ENTRY * entry, short datatype) +zzip_mem_entry_find_extra_block(ZZIP_MEM_ENTRY * entry, short datatype, zzip_size_t blocksize) { int i = 2; while (1) @@ -287,7 +319,10 @@ zzip_mem_entry_extra_block(ZZIP_MEM_ENTRY * entry, short datatype) { if (datatype == zzip_extra_block_get_datatype(ext)) { - return ((ZZIP_EXTRA_BLOCK*) ext); + if (blocksize <= zzip_extra_block_get_datasize(ext) + zzip_extra_block_headerlength) + { + return ((ZZIP_EXTRA_BLOCK*) ext); + } } /* skip to start of next extra_block */ ___ zzip_size_t datasize = zzip_extra_block_get_datasize(ext); @@ -348,7 +383,7 @@ zzip_mem_disk_close(ZZIP_MEM_DISK * _zzip_restrict dir) static void foo(short zz_datatype) { - /* Header IDs of 0 thru 31 are reserved for use by PKWARE.(APPNOTE.TXT) */ + /* Header IDs of 0 through 31 are reserved for use by PKWARE.(APPNOTE.TXT) */ switch (zz_datatype) { /* *INDENT-OFF* */ diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.h b/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.h index 850d7ed4de7..5cf0eced460 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/memdisk.h @@ -9,6 +9,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -43,7 +44,9 @@ zzip_mem_disk_load (ZZIP_MEM_DISK* dir, ZZIP_DISK* disk); zzip_mem_disk_extern void zzip_mem_disk_unload (ZZIP_MEM_DISK* dir); ZZIP_EXTRA_BLOCK* -zzip_mem_entry_extra_block (ZZIP_MEM_ENTRY* entry, short datatype); +zzip_mem_entry_extra_block (ZZIP_MEM_ENTRY* entry, short datatype) ZZIP_GNUC_DEPRECATED; +ZZIP_EXTRA_BLOCK* +zzip_mem_entry_find_extra_block (ZZIP_MEM_ENTRY* entry, short datatype, zzip_size_t blocksize); #ifdef USE_INLINE _zzip_inline ZZIP_DISK* zzip_disk (ZZIP_MEM_DISK* dir) { return dir->disk; } @@ -73,9 +76,9 @@ struct _zzip_mem_entry { zzip_size_t zz_extlen[3]; /* the extra blocks are NOT converted */ }; -#define _zzip_mem_disk_findfirst(_d_) ((_d_)->list) -#define _zzip_mem_disk_findnext(_d_,_e_) (!(_e_)?(_d_)->list:(_e_)->zz_next) -#define _zzip_mem_entry_findnext(_e_) ((_e_)->zz_next) +#define _zzip_mem_disk_findfirst(_d_) (!(_d_) ? 0 : ((_d_)->list)) +#define _zzip_mem_disk_findnext(_d_,_e_) (!(_e_) ? (!(_d_) ? 0 : ((_d_)->list)) : ((_e_)->zz_next)) +#define _zzip_mem_entry_findnext(_e_) (!(_e_) ? 0 : ((_e_)->zz_next)) #ifndef USE_INLINE #define zzip_mem_disk_findfirst _zzip_mem_disk_findfirst @@ -97,10 +100,10 @@ zzip_mem_entry_findnext(ZZIP_MEM_ENTRY* entry) { return _zzip_mem_entry_findnext(entry); } #endif -#define _zzip_mem_entry_to_name(_e_) ((_e_)->zz_name) -#define _zzip_mem_entry_to_comment(_e_) ((_e_)->zz_comment) -#define _zzip_mem_entry_strdup_name(_e_) (strdup((_e_)->zz_name)) -#define _zzip_mem_entry_to_data(_e_) ((_e_)->zz_data) +#define _zzip_mem_entry_to_name(_e_) (!(_e_) ? 0 : ((_e_)->zz_name)) +#define _zzip_mem_entry_to_comment(_e_) (!(_e_) ? 0 : ((_e_)->zz_comment)) +#define _zzip_mem_entry_strdup_name(_e_) (!(_e_) ? 0 : (strdup((_e_)->zz_name))) +#define _zzip_mem_entry_to_data(_e_) (!(_e_) ? 0 : ((_e_)->zz_data)) #ifndef USE_INLINE #define zzip_mem_entry_to_name _zzip_mem_entry_to_name diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.c b/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.c index 67f293fb0d1..c61fc5656b6 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.c @@ -30,8 +30,11 @@ #include #include #include +#include #include +#include #include +#include #include #include @@ -57,18 +60,6 @@ #define ____ } #endif -#ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) -#else -#define debug1(msg) -#define debug2(msg, arg1) -#define debug3(msg, arg1, arg2) -#define debug4(msg, arg1, arg2, arg3) -#endif - /** => zzip_disk_mmap * This function does primary initialization of a disk-buffer struct. * @@ -151,7 +142,7 @@ zzip_disk_munmap(ZZIP_DISK * disk) * to => zzip_disk_mmap for bringing it to main memory. If it can not * be => mmap(2)'ed then we slurp the whole file into a newly => malloc(2)'ed * memory block. Only if that fails too then we return null. Since handling - * of disk->buffer is ambigous it should not be snatched away please. + * of disk->buffer is ambiguous it should not be snatched away please. * * This function may return null on errors (errno). */ @@ -225,7 +216,7 @@ zzip_disk_buffer(void *buffer, size_t buflen) { * zip archive, including any malloc()ed blocks, sharedmem mappings * and it dumps the handle struct as well. * - * This function returns 0 on sucess (or whatever => munmap says). + * This function returns 0 on success (or whatever => munmap says). */ int zzip_disk_close(ZZIP_DISK * disk) @@ -241,55 +232,8 @@ zzip_disk_close(ZZIP_DISK * disk) } /* ====================================================================== */ - /* helper functions */ -#ifdef ZZIP_HAVE_STRNDUP -#define _zzip_strndup strndup -#else - -/* if your system does not have strndup: */ -zzip__new__ static char * -_zzip_strndup(char *p, size_t maxlen) -{ - if (! p) - return 0; - ___ zzip_byte_t *r = malloc(maxlen + 1); - if (! r) - return r; - strncpy(r, p, maxlen); - r[maxlen] = '\0'; - return r; - ____; -} -#endif - -#if defined ZZIP_HAVE_STRCASECMP || defined strcasecmp -#define _zzip_strcasecmp strcasecmp -#else - -/* if your system does not have strcasecmp: */ -static int -_zzip_strcasecmp(char *__zzip_restrict a, char *_zzip_restrict b) -{ - if (! a) - return (b) ? 1 : 0; - if (! b) - return -1; - while (1) - { - int v = tolower(*a) - tolower(*b); - if (v) - return v; - if (! *a) - return 1; - if (! *b) - return -1; - a++; - b++; - } -} -#endif /** helper functions for (mmapped) zip access api * @@ -453,16 +397,16 @@ zzip_disk_entry_strdup_comment(ZZIP_DISK * disk, struct zzip_disk_entry *entry) struct zzip_disk_entry * zzip_disk_findfirst(ZZIP_DISK * disk) { - debug1("findfirst"); + DBG1("findfirst"); if (! disk) { - debug1("non arg"); + DBG1("non arg"); errno = EINVAL; return 0; } if (disk->buffer > disk->endbuf - sizeof(struct zzip_disk_trailer)) { - debug1("not enough data for a disk trailer"); + DBG1("not enough data for a disk trailer"); errno = EBADMSG; return 0; } @@ -475,12 +419,12 @@ zzip_disk_findfirst(ZZIP_DISK * disk) struct zzip_disk_trailer *trailer = (struct zzip_disk_trailer *) p; zzip_size_t rootseek = zzip_disk_trailer_get_rootseek(trailer); root = disk->buffer + rootseek; - debug2("disk rootseek at %lli", (long long)rootseek); + DBG2("disk rootseek at %lli", (long long)rootseek); if (root > p) { /* the first disk_entry is after the disk_trailer? can't be! */ zzip_size_t rootsize = zzip_disk_trailer_get_rootsize(trailer); - debug2("have rootsize at %lli", (long long)rootsize); + DBG2("have rootsize at %lli", (long long)rootsize); if (disk->buffer + rootsize > p) continue; /* a common brokeness that can be fixed: we just assume the @@ -493,12 +437,12 @@ zzip_disk_findfirst(ZZIP_DISK * disk) (struct zzip_disk64_trailer *) p; if (sizeof(void *) < 8) { - debug1("disk64 trailer in non-largefile part"); + DBG1("disk64 trailer in non-largefile part"); errno = EFBIG; return 0; } zzip_size_t rootseek = zzip_disk64_trailer_get_rootseek(trailer); - debug2("disk64 rootseek at %lli", (long long)rootseek); + DBG2("disk64 rootseek at %lli", (long long)rootseek); root = disk->buffer + rootseek; if (root > p) continue; @@ -507,16 +451,16 @@ zzip_disk_findfirst(ZZIP_DISK * disk) continue; } - debug4("buffer %p root %p endbuf %p", disk->buffer, root, disk->endbuf); + DBG4("buffer %p root %p endbuf %p", disk->buffer, root, disk->endbuf); if (root < disk->buffer) { - debug1("root before buffer should be impossible"); + DBG1("root before buffer should be impossible"); errno = EBADMSG; return 0; } if (zzip_disk_entry_check_magic(root)) { - debug1("found the disk root"); + DBG2("found the disk root %p", root); return (struct zzip_disk_entry *) root; } } ____; @@ -630,7 +574,7 @@ zzip_disk_findmatch(ZZIP_DISK * disk, char *filespec, { compare = (zzip_fnmatch_fn_t) _zzip_fnmatch; if (disk->flags & ZZIP_DISK_FLAGS_MATCH_NOCASE) - flags |= _zzip_fnmatch_CASEFOLD; + flags |= _zzip_FNM_CASEFOLD; } for (; entry; entry = zzip_disk_findnext(disk, entry)) { @@ -682,7 +626,13 @@ zzip_disk_entry_fopen(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry) file->avail = zzip_file_header_usize(header); if (! file->avail || zzip_file_header_data_stored(header)) - { file->stored = zzip_file_header_to_data (header); return file; } + { + file->stored = zzip_file_header_to_data (header); + DBG2("stored size %i", (int) file->avail); + if (file->stored + file->avail >= disk->endbuf) + goto error; + return file; + } file->stored = 0; file->zlib.opaque = 0; @@ -691,15 +641,20 @@ zzip_disk_entry_fopen(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry) file->zlib.avail_in = zzip_file_header_csize(header); file->zlib.next_in = zzip_file_header_to_data(header); - if (! zzip_file_header_data_deflated(header) || - inflateInit2(&file->zlib, -MAX_WBITS) != Z_OK) - { - free (file); - errno = EBADMSG; - return 0; - } + DBG2("compressed size %i", (int) file->zlib.avail_in); + if (file->zlib.next_in + file->zlib.avail_in >= disk->endbuf) + goto error; + + if (! zzip_file_header_data_deflated(header)) + goto error; + if (inflateInit2(&file->zlib, -MAX_WBITS) != Z_OK) + goto error; return file; +error: + free (file); + errno = EBADMSG; + return 0; ____; } @@ -738,6 +693,12 @@ zzip_disk_fread(void *ptr, zzip_size_t sized, zzip_size_t nmemb, size = file->avail; if (file->stored) { + if (file->stored + size >= file->endbuf) + { + DBG1("try to read beyond end of file"); + return 0; /* ESPIPE */ + } + DBG3("copy stored %p %i", file->stored, (int)size); memcpy(ptr, file->stored, size); file->stored += size; file->avail -= size; diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.h b/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.h index 00e6c5537e7..652ad293233 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/mmapped.h @@ -28,7 +28,7 @@ typedef struct zzip_disk ZZIP_DISK; /* we expose this structure so third party applications can augment * on them. The mmapped zip access usually just needs the two pointers - * specifying the mmapped area, whereever you have that from. + * specifying the mmapped area, wherever you have that from. */ struct zzip_disk { diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/write.c b/Build/source/libs/zziplib/zziplib-src/zzip/write.c index cc09c5b9e81..cfec8164931 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/write.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/write.c @@ -1,4 +1,3 @@ - /* * The write-support in zziplib is not a full-flegded interface to the * internals that zip file-header or zip archive an contain. It's @@ -6,7 +5,7 @@ * where time-stamps are rather unimportant. Here we can create an * archive with filenames and their data portions, possibly obfuscated. * - * DONT USE THIS + * DON'T USE THIS * * The write support is supposed to be added directly into the main * zziplib but it has not been implemented so far. It does however @@ -43,6 +42,7 @@ #include #include +#include #include #define ___ { @@ -71,12 +71,6 @@ # define S_IRWXO 00007 # endif -# ifdef ZZIP_HAVE_DIRECT_H -# define _mkdir(a,b) mkdir(a) -# else -# define _mkdir mkdir -# endif - /** create a new zip archive for writing * * This function will create a new zip archive. The returned parameter @@ -136,7 +130,7 @@ zzip_dir_creat_ext_io(zzip_char_t * name, int o_mode, /* not implemented - however, we respect that a null argument to * zzip_mkdir and zzip_creat works, so we silently still do the mkdir */ - if (! _mkdir(name, o_mode) || errno == EEXIST) + if (! _zzip_mkdir(name, o_mode) || errno == EEXIST) errno = EROFS; return 0; } else @@ -218,7 +212,7 @@ zzip_createdir(zzip_char_t * name, int o_mode) { if (o_mode & S_IWGRP) { - if (-1 == _mkdir(name, o_mode) && errno != EEXIST) /* fail */ + if (-1 == _zzip_mkdir(name, o_mode) && errno != EEXIST) /* fail */ return 0; return zzip_opendir(name); } else @@ -261,7 +255,7 @@ int zzip_file_mkdir(ZZIP_DIR * dir, zzip_char_t * name, int o_mode) { if (! dir) - return _mkdir(name, o_mode); + return _zzip_mkdir(name, o_mode); if (! _ZZIP_TRY) { /* not implemented */ diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zip.c b/Build/source/libs/zziplib/zziplib-src/zzip/zip.c index fbca9951d17..d0b2d6e4196 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/zip.c +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zip.c @@ -320,6 +320,12 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, # endif __fixup_rootseek(offset + tail - mapped, trailer); + /* + * "extract data from files archived in a single zip file." + * So the file offsets must be within the current ZIP archive! + */ + if (trailer->zz_rootseek >= filesize || (trailer->zz_rootseek + trailer->zz_rootsize) >= filesize) + return(ZZIP_CORRUPTED); { return(0); } } else if ((*tail == 'P') && end - tail >= @@ -338,6 +344,12 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, zzip_disk64_trailer_finalentries(orig); trailer->zz_rootseek = zzip_disk64_trailer_rootseek(orig); trailer->zz_rootsize = zzip_disk64_trailer_rootsize(orig); + /* + * "extract data from files archived in a single zip file." + * So the file offsets must be within the current ZIP archive! + */ + if (trailer->zz_rootseek >= filesize || (trailer->zz_rootseek + trailer->zz_rootsize) >= filesize) + return(ZZIP_CORRUPTED); { return(0); } # endif } @@ -630,7 +642,7 @@ zzip_dir_alloc(zzip_strings_t * fileext) * are helper functions used implicitly in other zzipcalls * e.g. => zzip_dir_close = zzip_close * - * returns zero on sucess + * returns zero on success * returns the refcount when files are attached. */ int diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zzip-zlib-config.pc b/Build/source/libs/zziplib/zziplib-src/zzip/zzip-zlib-config.pc new file mode 100644 index 00000000000..39097d41dfa --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zzip-zlib-config.pc @@ -0,0 +1,8 @@ +zlib_libs= -lz +zlib_cflags= + +Name: zzip-zlib-config +Version: 1.2.8 +Description: ZLib Config (for ZZipLib) +Libs: ${zlib_libs} +Cflags: ${zlib_cflags} diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zzip.h b/Build/source/libs/zziplib/zziplib-src/zzip/zzip.h index 6f6788f7113..3941acc7011 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/zzip.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zzip.h @@ -163,7 +163,7 @@ _zzip_export void zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset); /* - * 'opening', 'closing' and reading invidual files in zip archive. + * 'opening', 'closing' and reading individual files in zip archive. * zzip/file.c */ _zzip_export diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zzipfseeko.pc b/Build/source/libs/zziplib/zziplib-src/zzip/zzipfseeko.pc new file mode 100644 index 00000000000..336240cc427 --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zzipfseeko.pc @@ -0,0 +1,18 @@ +# generated by configure / remove this line to disable regeneration +prefix=/usr/local +exec_prefix=${prefix} +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib64 +datarootdir=${prefix}/share +datadir=${datarootdir} +sysconfdir=${prefix}/etc +includedir=${prefix}/include +package=zzipfseeko +suffix= + +Name: zzipfseeko +Description: ZZipLib - libZ-based ZIP-access Library with an Easy-to-Use API +Version: 0.13.68 +Requires: zzip-zlib-config +Libs: -L${libdir} -lzzipfseeko +Cflags: -I${includedir} diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zziplib.pc b/Build/source/libs/zziplib/zziplib-src/zzip/zziplib.pc new file mode 100644 index 00000000000..21eb50234af --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zziplib.pc @@ -0,0 +1,18 @@ +# generated by configure / remove this line to disable regeneration +prefix=/usr/local +exec_prefix=${prefix} +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib64 +datarootdir=${prefix}/share +datadir=${datarootdir} +sysconfdir=${prefix}/etc +includedir=${prefix}/include +package=zziplib +suffix= + +Name: zziplib +Description: ZZipLib - libZ-based ZIP-access Library with an Easy-to-Use API +Version: 0.13.68 +Requires: zzip-zlib-config +Libs: -L${libdir} -lzzip +Cflags: -I${includedir} diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/zzipmmapped.pc b/Build/source/libs/zziplib/zziplib-src/zzip/zzipmmapped.pc new file mode 100644 index 00000000000..e4e99a086be --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/zzipmmapped.pc @@ -0,0 +1,18 @@ +# generated by configure / remove this line to disable regeneration +prefix=/usr/local +exec_prefix=${prefix} +bindir=${exec_prefix}/bin +libdir=${exec_prefix}/lib64 +datarootdir=${prefix}/share +datadir=${datarootdir} +sysconfdir=${prefix}/etc +includedir=${prefix}/include +package=zzipmmapped +suffix= + +Name: zzipmmapped +Description: ZZipLib - libZ-based ZIP-access Library with an Easy-to-Use API +Version: 0.13.68 +Requires: zzip-zlib-config +Libs: -L${libdir} -lzzipmmapped +Cflags: -I${includedir} -- cgit v1.2.3