Skip to content

Commit

Permalink
Upgrade minizip to 3.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jhudsonWA committed Dec 17, 2022
1 parent 6a5a46e commit 3016df0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
@@ -1,5 +1,5 @@
PODS:
- SSZipArchive (2.5.1)
- SSZipArchive (2.5.3)

DEPENDENCIES:
- SSZipArchive (from `..`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: ".."

SPEC CHECKSUMS:
SSZipArchive: 838576d09fe0196781dacb1c589d193604d22353
SSZipArchive: d3ea9f5e15234229a8d7e164c2789a82b7c19440

PODFILE CHECKSUM: 570af5c3534cb262ca98be3dedfff7caa40f00ed

Expand Down
2 changes: 1 addition & 1 deletion SSZipArchive.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SSZipArchive'
s.version = '2.5.2'
s.version = '2.5.3'
s.summary = 'Utility class for zipping and unzipping files on iOS, tvOS, watchOS, and macOS.'
s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS, tvOS, watchOS, and macOS. It supports AES and PKWARE encryption.'
s.homepage = 'https://github.com/ZipArchive/ZipArchive'
Expand Down
4 changes: 2 additions & 2 deletions SSZipArchive/minizip/mz.h
Expand Up @@ -14,8 +14,8 @@
/***************************************************************************/

/* MZ_VERSION */
#define MZ_VERSION ("3.0.6")
#define MZ_VERSION_BUILD (030006)
#define MZ_VERSION ("3.0.7")
#define MZ_VERSION_BUILD (030007)

/* MZ_ERROR */
#define MZ_OK (0) /* zlib */
Expand Down
3 changes: 2 additions & 1 deletion SSZipArchive/minizip/mz_os.h
Expand Up @@ -41,8 +41,9 @@ extern "C" {
(MZ_VERSION_MADEBY_ZIP_VERSION))

#define MZ_PATH_SLASH_UNIX ('/')
#define MZ_PATH_SLASH_WINDOWS ('\\')
#if defined(_WIN32)
# define MZ_PATH_SLASH_PLATFORM ('\\')
# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_WINDOWS)
#else
# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_UNIX)
#endif
Expand Down
41 changes: 18 additions & 23 deletions SSZipArchive/minizip/mz_os_posix.c
Expand Up @@ -34,11 +34,7 @@
# include <sys/random.h>
#endif
#if defined(HAVE_LIBBSD)
# include <sys/types.h>
# ifndef __u_char_defined
typedef unsigned char u_char;
# endif
# include <bsd/stdlib.h> /* arc4random_buf */
# include <stdlib.h> /* arc4random_buf */
#endif

/***************************************************************************/
Expand Down Expand Up @@ -117,7 +113,22 @@ void mz_os_utf8_string_delete(uint8_t **string) {

/***************************************************************************/

#if defined(HAVE_ARC4RANDOM_BUF)
#if defined(HAVE_GETRANDOM)
int32_t mz_os_rand(uint8_t *buf, int32_t size) {
int32_t left = size;
int32_t written = 0;

while (left > 0) {
written = getrandom(buf, left, 0);
if (written < 0)
return MZ_INTERNAL_ERROR;

buf += written;
left -= written;
}
return size - left;
}
#elif defined(HAVE_ARC4RANDOM_BUF)
int32_t mz_os_rand(uint8_t *buf, int32_t size) {
if (size < 0)
return 0;
Expand All @@ -139,21 +150,6 @@ int32_t mz_os_rand(uint8_t *buf, int32_t size) {
}
return size - left;
}
#elif defined(HAVE_GETRANDOM)
int32_t mz_os_rand(uint8_t *buf, int32_t size) {
int32_t left = size;
int32_t written = 0;

while (left > 0) {
written = getrandom(buf, left, 0);
if (written < 0)
return MZ_INTERNAL_ERROR;

buf += written;
left -= written;
}
return size - left;
}
#else
int32_t mz_os_rand(uint8_t *buf, int32_t size) {
static unsigned calls = 0;
Expand Down Expand Up @@ -222,8 +218,7 @@ int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *acc
/* Not all systems allow stat'ing a file with / appended */
len = strlen(path);
name = (char *)malloc(len + 1);
strncpy(name, path, len);
name[len - 1] = 0;
strncpy(name, path, len + 1);
mz_path_remove_slash(name);

if (stat(name, &path_stat) == 0) {
Expand Down
32 changes: 26 additions & 6 deletions SSZipArchive/minizip/mz_zip.c
Expand Up @@ -188,6 +188,7 @@ static int32_t mz_zip_search_zip64_eocd(void *stream, const int64_t end_central_
return err;
}

#ifdef HAVE_PKCRYPT
/* Get PKWARE traditional encryption verifier */
static uint16_t mz_zip_get_pk_verify(uint32_t dos_date, uint64_t crc, uint16_t flag)
{
Expand All @@ -197,6 +198,7 @@ static uint16_t mz_zip_get_pk_verify(uint32_t dos_date, uint64_t crc, uint16_t f
return ((dos_date >> 16) & 0xff) << 8 | ((dos_date >> 8) & 0xff);
return ((crc >> 16) & 0xff) << 8 | ((crc >> 24) & 0xff);
}
#endif

/* Get info about the current file in the zip file */
static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file *file_info, void *file_extra_stream) {
Expand Down Expand Up @@ -787,8 +789,26 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
}

if (err == MZ_OK) {
if (mz_stream_write(stream, filename, filename_length) != filename_length)
err = MZ_WRITE_ERROR;
const char *backslash = NULL;
const char *next = filename;
int32_t left = filename_length;

/* Ensure all slashes are written as forward slashes according to 4.4.17.1 */
while ((err == MZ_OK) && (backslash = strrchr(next, '\\')) != NULL) {
int32_t part_length = (int32_t)(backslash - next);

if (mz_stream_write(stream, next, part_length) != part_length ||
mz_stream_write(stream, "/", 1) != 1)
err = MZ_WRITE_ERROR;

left -= part_length + 1;
next = backslash + 1;
}

if (err == MZ_OK && left > 0) {
if (mz_stream_write(stream, next, left) != left)
err = MZ_WRITE_ERROR;
}

/* Ensure that directories have a slash appended to them for compatibility */
if (err == MZ_OK && write_end_slash)
Expand Down Expand Up @@ -2500,11 +2520,11 @@ int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t targ
if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS))
return mz_zip_attrib_win32_to_posix(src_attrib, target_attrib);
} else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) {
if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) {
/* If high bytes are set, it contains unix specific attributes */
if ((src_attrib >> 16) != 0)
src_attrib >>= 16;
/* If high bytes are set, it contains unix specific attributes */
if ((src_attrib >> 16) != 0)
src_attrib >>= 16;

if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) {
*target_attrib = src_attrib;
return MZ_OK;
}
Expand Down

0 comments on commit 3016df0

Please sign in to comment.