Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7855c3efd0 | ||
|
|
c689d51f79 | ||
|
|
fee885a931 | ||
|
|
a1e78c5fc4 | ||
|
|
3c52d21ba9 | ||
|
|
fc746532d8 | ||
|
|
d60c6d20af | ||
|
|
55e4fe414e | ||
|
|
5bb372d495 | ||
|
|
a86a4355da | ||
|
|
c9fd8d4df0 | ||
|
|
02123b82d5 | ||
|
|
7140c588c6 | ||
|
|
f60a99bd90 | ||
|
|
50fd547660 | ||
|
|
2fa05a7264 | ||
|
|
1a20b75c46 | ||
|
|
dab094fc31 | ||
|
|
13a12e32ab | ||
|
|
73418b7e05 | ||
|
|
3f7de8e289 | ||
|
|
18a30653b1 | ||
|
|
b73887478a | ||
|
|
51fb0afc82 | ||
|
|
a45fa6b8a0 | ||
|
|
6c6700d2f4 | ||
|
|
0574424b05 | ||
|
|
919d837abf | ||
|
|
12db0fc415 | ||
|
|
e4bd6d3191 | ||
|
|
f9749af452 | ||
|
|
02a516944d | ||
|
|
0d4ae83bd2 | ||
|
|
d15b013734 | ||
|
|
a3dc63a17f | ||
|
|
be85b3b4cd | ||
|
|
3da621e118 | ||
|
|
211f14074a | ||
|
|
819d0d56f0 | ||
|
|
fa7fadebfa | ||
|
|
a6e7d468e3 | ||
|
|
b8f7cf0fa7 | ||
|
|
886df95632 | ||
|
|
80c2d56436 |
+1
-1
@@ -23,4 +23,4 @@ before_script:
|
||||
script:
|
||||
- make
|
||||
- cd ../test
|
||||
- python test.py --exe_dir=../build
|
||||
- travis_wait 30 python test.py --exe_dir=../build
|
||||
|
||||
+9
-7
@@ -27,7 +27,7 @@ set(INSTALL_PKGCONFIG_DIR "share/pkgconfig" CACHE PATH "Installation directory f
|
||||
|
||||
project("minizip")
|
||||
|
||||
set(VERSION "2.2.4")
|
||||
set(VERSION "2.2.6")
|
||||
|
||||
# Set cmake debug postfix to d
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
@@ -81,7 +81,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -O3")
|
||||
add_compile_options(-fPIC -O3)
|
||||
|
||||
list(APPEND MINIZIP_SRC "src/mz_os_posix.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "src/mz_os_posix.h")
|
||||
@@ -89,14 +89,16 @@ if(UNIX)
|
||||
add_definitions(-D__USE_FILE_OFFSET64)
|
||||
add_definitions(-D__USE_LARGEFILE64)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
add_definitions(-D_FILE_OFFSET_BIT=64)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(LIBBSD libbsd)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
pkg_check_modules(LIBBSD libbsd REQUIRED)
|
||||
|
||||
include_directories(${LIBBSD_INCLUDE_DIRS})
|
||||
link_directories(${LIBBSD_LIBRARY_DIRS})
|
||||
include_directories(${LIBBSD_INCLUDE_DIRS})
|
||||
link_directories(${LIBBSD_LIBRARY_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_CRYPT)
|
||||
@@ -274,7 +276,7 @@ if(USE_LZMA)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER MATCHES ".*clang")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -msse4.1 -maes")
|
||||
add_compile_options(-msse3 -msse4.1 -maes)
|
||||
endif()
|
||||
|
||||
# Create minizip library
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Minizip'
|
||||
s.version = '2.2.4'
|
||||
s.version = '2.2.6'
|
||||
s.license = 'zlib'
|
||||
s.summary = 'Minizip contrib in zlib with the latest bug fixes and advanced features'
|
||||
s.description = <<-DESC
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Minizip 2.2.4
|
||||
# Minizip 2.2.6
|
||||
|
||||
This library is a refactoring of the minizip contribution found in the zlib distribution that is supported on Windows, macOS, and Linux. The motivation for this work has been the inclusion of advanced features, improvements in code maintainability and readability, and the reduction of duplicate code. It is based on the original work of [Gilles Vollant](http://www.winimage.com/zLibDll/minizip.html) that has been contributed to by many people over the years.
|
||||
|
||||
@@ -57,7 +57,7 @@ cmake --build .
|
||||
#### [WinZIP AES Encryption](http://www.winzip.com/aes_info.htm)
|
||||
|
||||
+ Requires ``cmake . -DUSE_AES=ON`` or ``#define HAVE_AES``
|
||||
+ Requires [Brian Gladman's](https://github.com/BrianGladman/aes) AES library
|
||||
+ Requires Brian Gladman's [AES](https://github.com/BrianGladman/aes) and [SHA](https://github.com/BrianGladman/sha) libraries
|
||||
|
||||
When zipping with a password it will always use AES 256-bit encryption.
|
||||
When unzipping it will use AES decryption only if necessary.
|
||||
|
||||
@@ -23,6 +23,7 @@ a password and a salt value.
|
||||
|
||||
#include <string.h>
|
||||
#include "hmac.h"
|
||||
#include "pwd2key.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
|
||||
Executable → Regular
+23
-6
@@ -1,8 +1,8 @@
|
||||
/* minizip.c
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "mz.h"
|
||||
#include "mz_os.h"
|
||||
#include "mz_strm.h"
|
||||
#include "mz_strm_buf.h"
|
||||
#include "mz_strm_split.h"
|
||||
#include "mz_zip.h"
|
||||
|
||||
@@ -45,6 +46,7 @@ void minizip_help()
|
||||
" -d Destination directory\n" \
|
||||
" -o Overwrite existing files\n" \
|
||||
" -a Append to existing zip file\n" \
|
||||
" -u Buffered reading and writing\n" \
|
||||
" -j Exclude path of files\n" \
|
||||
" -0 Store only\n" \
|
||||
" -1 Compress faster\n" \
|
||||
@@ -529,6 +531,7 @@ int main(int argc, char *argv[])
|
||||
void *handle = NULL;
|
||||
void *file_stream = NULL;
|
||||
void *split_stream = NULL;
|
||||
void *buf_stream = NULL;
|
||||
char *path = NULL;
|
||||
char *password = NULL;
|
||||
char *destination = NULL;
|
||||
@@ -538,6 +541,7 @@ int main(int argc, char *argv[])
|
||||
int32_t path_arg = 0;
|
||||
uint8_t do_list = 0;
|
||||
uint8_t do_extract = 0;
|
||||
uint8_t buffered = 0;
|
||||
int16_t mode = 0;
|
||||
uint8_t append = 0;
|
||||
int32_t err_close = 0;
|
||||
@@ -572,6 +576,8 @@ int main(int argc, char *argv[])
|
||||
do_extract = 1;
|
||||
if ((c == 'a') || (c == 'A'))
|
||||
append = 1;
|
||||
if ((c == 'u') || (c == 'U'))
|
||||
buffered = 1;
|
||||
if ((c == 'o') || (c == 'O'))
|
||||
options.overwrite = 1;
|
||||
if ((c == 'j') || (c == 'J'))
|
||||
@@ -595,7 +601,7 @@ int main(int argc, char *argv[])
|
||||
if ((c == 's') || (c == 'S'))
|
||||
options.aes = 1;
|
||||
#endif
|
||||
if (((c == 'k') || (c == 'k')) && (i + 1 < argc))
|
||||
if (((c == 'k') || (c == 'K')) && (i + 1 < argc))
|
||||
{
|
||||
disk_size = atoi(argv[i + 1]) * 1024;
|
||||
i += 1;
|
||||
@@ -676,9 +682,19 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
mz_stream_os_create(&file_stream);
|
||||
|
||||
mz_stream_buffered_create(&buf_stream);
|
||||
mz_stream_split_create(&split_stream);
|
||||
mz_stream_set_base(split_stream, file_stream);
|
||||
|
||||
if (buffered)
|
||||
{
|
||||
mz_stream_set_base(buf_stream, file_stream);
|
||||
mz_stream_set_base(split_stream, buf_stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
mz_stream_set_base(split_stream, file_stream);
|
||||
}
|
||||
|
||||
mz_stream_split_set_prop_int64(split_stream, MZ_STREAM_PROP_DISK_SIZE, disk_size);
|
||||
|
||||
err = mz_stream_open(split_stream, path, mode);
|
||||
@@ -734,10 +750,11 @@ int main(int argc, char *argv[])
|
||||
err = err_close;
|
||||
}
|
||||
|
||||
mz_stream_os_close(file_stream);
|
||||
mz_stream_close(split_stream);
|
||||
}
|
||||
|
||||
mz_stream_split_delete(&split_stream);
|
||||
mz_stream_buffered_delete(&buf_stream);
|
||||
mz_stream_os_delete(&file_stream);
|
||||
|
||||
return err;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* mz.h -- Errors codes, zip flags and magic
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
/***************************************************************************/
|
||||
|
||||
// MZ_VERSION
|
||||
#define MZ_VERSION ("2.2.4")
|
||||
#define MZ_VERSION ("2.2.6")
|
||||
|
||||
// MZ_ERROR
|
||||
#define MZ_OK (0)
|
||||
@@ -34,6 +34,7 @@ extern "C" {
|
||||
#define MZ_CRC_ERROR (-105)
|
||||
#define MZ_CRYPT_ERROR (-106)
|
||||
#define MZ_EXIST_ERROR (-107)
|
||||
#define MZ_PASSWORD_ERROR (-108)
|
||||
|
||||
// MZ_OPEN
|
||||
#define MZ_OPEN_MODE_READ (0x01)
|
||||
|
||||
+29
-13
@@ -1,8 +1,8 @@
|
||||
/* mz_compat.c -- Backwards compatible interface for older versions
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
@@ -34,12 +34,14 @@ typedef struct mz_compat_s {
|
||||
|
||||
extern zipFile ZEXPORT zipOpen(const char *path, int append)
|
||||
{
|
||||
return zipOpen2(path, append, NULL, mz_stream_os_get_interface());
|
||||
zlib_filefunc64_def pzlib = mz_stream_os_get_interface();
|
||||
return zipOpen2(path, append, NULL, &pzlib);
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen64(const void *path, int append)
|
||||
{
|
||||
return zipOpen2(path, append, NULL, mz_stream_os_get_interface());
|
||||
zlib_filefunc64_def pzlib = mz_stream_os_get_interface();
|
||||
return zipOpen2(path, append, NULL, &pzlib);
|
||||
}
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment,
|
||||
@@ -57,7 +59,7 @@ extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **gl
|
||||
void *handle = NULL;
|
||||
void *stream = NULL;
|
||||
|
||||
if (mz_stream_create(&stream, (mz_stream_vtbl *)pzlib_filefunc_def) == NULL)
|
||||
if (mz_stream_create(&stream, (mz_stream_vtbl *)*pzlib_filefunc_def) == NULL)
|
||||
return NULL;
|
||||
|
||||
switch (append)
|
||||
@@ -129,6 +131,9 @@ extern int ZEXPORT zipOpenNewFileInZip5(zipFile file, const char *filename, cons
|
||||
file_info.aes_version = MZ_AES_VERSION;
|
||||
#endif
|
||||
|
||||
if (raw)
|
||||
level = 0;
|
||||
|
||||
return mz_zip_entry_write_open(compat->handle, &file_info, (int16_t)level, password);
|
||||
}
|
||||
|
||||
@@ -246,7 +251,8 @@ extern unzFile ZEXPORT unzOpen(const char *path)
|
||||
|
||||
extern unzFile ZEXPORT unzOpen64(const void *path)
|
||||
{
|
||||
return unzOpen2(path, mz_stream_os_get_interface());
|
||||
zlib_filefunc64_def pzlib = mz_stream_os_get_interface();
|
||||
return unzOpen2(path, &pzlib);
|
||||
}
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def)
|
||||
@@ -261,7 +267,7 @@ extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_
|
||||
void *handle = NULL;
|
||||
void *stream = NULL;
|
||||
|
||||
if (mz_stream_create(&stream, (mz_stream_vtbl *)pzlib_filefunc_def) == NULL)
|
||||
if (mz_stream_create(&stream, (mz_stream_vtbl *)*pzlib_filefunc_def) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (mz_stream_open(stream, path, mode) != MZ_OK)
|
||||
@@ -282,6 +288,7 @@ extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_
|
||||
compat->handle = handle;
|
||||
compat->stream = stream;
|
||||
|
||||
mz_zip_goto_first_entry(compat->handle);
|
||||
return (unzFile)compat;
|
||||
}
|
||||
|
||||
@@ -296,7 +303,10 @@ extern int ZEXPORT unzClose(unzFile file)
|
||||
err = mz_zip_close(compat->handle);
|
||||
|
||||
if (compat->stream != NULL)
|
||||
{
|
||||
mz_stream_close(compat->stream);
|
||||
mz_stream_delete(&compat->stream);
|
||||
}
|
||||
|
||||
free(compat);
|
||||
|
||||
@@ -490,7 +500,10 @@ extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile
|
||||
if (bytes_to_copy > file_info->filename_size)
|
||||
bytes_to_copy = file_info->filename_size;
|
||||
memcpy(filename, file_info->filename, bytes_to_copy);
|
||||
if (file_info->filename_size < filename_size)
|
||||
filename[file_info->filename_size] = 0;
|
||||
}
|
||||
|
||||
if (extrafield_size > 0 && extrafield != NULL)
|
||||
{
|
||||
bytes_to_copy = extrafield_size;
|
||||
@@ -498,12 +511,15 @@ extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile
|
||||
bytes_to_copy = file_info->extrafield_size;
|
||||
memcpy(extrafield, file_info->extrafield, bytes_to_copy);
|
||||
}
|
||||
|
||||
if (comment_size > 0 && comment != NULL)
|
||||
{
|
||||
bytes_to_copy = comment_size;
|
||||
if (bytes_to_copy > file_info->comment_size)
|
||||
bytes_to_copy = file_info->comment_size;
|
||||
memcpy(comment, file_info->comment, bytes_to_copy);
|
||||
if (file_info->comment_size < comment_size)
|
||||
comment[file_info->comment_size] = 0;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
@@ -538,37 +554,37 @@ extern int ZEXPORT unzLocateFile(unzFile file, const char *filename, unzFileName
|
||||
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
|
||||
{
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
|
||||
{
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
|
||||
{
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def)
|
||||
{
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def)
|
||||
{
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
|
||||
{
|
||||
// NOTE: You should no longer pass in widechar string to open function
|
||||
if (pzlib_filefunc_def != NULL)
|
||||
pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
*pzlib_filefunc_def = mz_stream_os_get_interface();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_compat.h -- Backwards compatible interface for older versions
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_os.c -- System functions
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_os.h -- System functions
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
/* mz_os_posix.c -- System functions for posix
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -21,8 +21,10 @@
|
||||
# include <unistd.h>
|
||||
# include <utime.h>
|
||||
#endif
|
||||
#if defined unix
|
||||
#if defined __linux__
|
||||
# include <bsd/stdlib.h>
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "mz.h"
|
||||
@@ -63,10 +65,8 @@ int64_t mz_posix_get_file_size(const char *path)
|
||||
int32_t mz_posix_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date)
|
||||
{
|
||||
struct stat stat_info;
|
||||
struct tm *filedate = NULL;
|
||||
char *name = NULL;
|
||||
size_t len = 0;
|
||||
time_t tm_t = 0;
|
||||
int32_t err = MZ_INTERNAL_ERROR;
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_os_posix.h -- System functions for posix
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
+2
-3
@@ -1,8 +1,8 @@
|
||||
/* mz_os_win32.c -- System functions for Windows
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -113,7 +113,6 @@ int64_t mz_win32_get_file_size(const char *path)
|
||||
HANDLE handle = NULL;
|
||||
LARGE_INTEGER large_size;
|
||||
wchar_t *path_wide = NULL;
|
||||
int32_t err = MZ_OK;
|
||||
|
||||
|
||||
path_wide = mz_win32_unicode_path_create(path);
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_os_win32.h -- System functions for Windows
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
Executable → Regular
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm.c -- Stream interface
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
Executable → Regular
+14
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm.h -- Stream interface
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -122,6 +122,18 @@ void* mz_stream_crc32_get_interface(void);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t mz_stream_raw_open(void *stream, const char *filename, int32_t mode);
|
||||
int32_t mz_stream_raw_is_open(void *stream);
|
||||
int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size);
|
||||
int32_t mz_stream_raw_write(void *stream, const void *buf, int32_t size);
|
||||
int64_t mz_stream_raw_tell(void *stream);
|
||||
int32_t mz_stream_raw_seek(void *stream, int64_t offset, int32_t origin);
|
||||
int32_t mz_stream_raw_close(void *stream);
|
||||
int32_t mz_stream_raw_error(void *stream);
|
||||
|
||||
int32_t mz_stream_raw_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
||||
|
||||
void* mz_stream_raw_create(void **stream);
|
||||
void mz_stream_raw_delete(void **stream);
|
||||
|
||||
|
||||
+6
-7
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_aes.c -- Stream for WinZip AES encryption
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2010 Brian Gladman, Worcester, UK
|
||||
|
||||
@@ -84,7 +84,6 @@ int32_t mz_stream_aes_open(void *stream, const char *path, int32_t mode)
|
||||
const char *password = path;
|
||||
int32_t password_length = 0;
|
||||
int32_t key_length = 0;
|
||||
int32_t err = MZ_OK;
|
||||
|
||||
aes->total_in = 0;
|
||||
aes->total_out = 0;
|
||||
@@ -117,12 +116,12 @@ int32_t mz_stream_aes_open(void *stream, const char *path, int32_t mode)
|
||||
|
||||
key_length = MZ_AES_KEY_LENGTH(aes->encryption_mode);
|
||||
// Derive the encryption and authentication keys and the password verifier
|
||||
derive_key(password, password_length, salt_value, salt_length,
|
||||
derive_key((const uint8_t *)password, password_length, salt_value, salt_length,
|
||||
MZ_AES_KEYING_ITERATIONS, kbuf, 2 * key_length + MZ_AES_PW_VERIFY_SIZE);
|
||||
|
||||
// Initialize the encryption nonce and buffer pos
|
||||
aes->encr_pos = AES_BLOCK_SIZE;
|
||||
memset(aes->nonce, 0, AES_BLOCK_SIZE * sizeof(unsigned char));
|
||||
memset(aes->nonce, 0, AES_BLOCK_SIZE * sizeof(uint8_t));
|
||||
|
||||
// Initialize for encryption using key 1
|
||||
aes_encrypt_key(kbuf, key_length, aes->encr_ctx);
|
||||
@@ -155,7 +154,7 @@ int32_t mz_stream_aes_open(void *stream, const char *path, int32_t mode)
|
||||
aes->total_in += MZ_AES_PW_VERIFY_SIZE;
|
||||
|
||||
if (memcmp(verify_expected, verify, MZ_AES_PW_VERIFY_SIZE) != 0)
|
||||
return MZ_STREAM_ERROR;
|
||||
return MZ_PASSWORD_ERROR;
|
||||
}
|
||||
|
||||
aes->mode = mode;
|
||||
@@ -172,7 +171,7 @@ int32_t mz_stream_aes_is_open(void *stream)
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_aes_encrypt_data(void *stream, uint8_t *buf, int32_t size)
|
||||
static int32_t mz_stream_aes_encrypt_data(void *stream, uint8_t *buf, int32_t size)
|
||||
{
|
||||
mz_stream_aes *aes = (mz_stream_aes *)stream;
|
||||
uint32_t pos = aes->encr_pos;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_aes.h -- Stream for WinZIP AES encryption
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
Executable → Regular
+32
-43
@@ -1,10 +1,10 @@
|
||||
/* mz_strm_buf.c -- Stream for buffering reads/writes
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
This version of ioapi is designed to buffer IO.
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -24,9 +24,9 @@
|
||||
/***************************************************************************/
|
||||
|
||||
#if 0
|
||||
# define mz_stream_buffered_print(o,s,f,...) printf(o,s,f,__VA_ARGS__);
|
||||
# define mz_stream_buffered_print(s,f,...) printf(f,__VA_ARGS__);
|
||||
#else
|
||||
# define mz_stream_buffered_print(o,s,f,...)
|
||||
# define mz_stream_buffered_print(s,f,...)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -66,17 +66,18 @@ typedef struct mz_stream_buffered_s {
|
||||
|
||||
int32_t mz_stream_buffered_open(void *stream, const char *path, int32_t mode)
|
||||
{
|
||||
//mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
//mz_stream_buffered_print(opaque, buffered, "open [mode %d]\n", mode);
|
||||
return mz_stream_open(stream, path, mode);
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
mz_stream_buffered_print(buffered, "open [mode %d]\n", mode);
|
||||
return mz_stream_open(buffered->stream.base, path, mode);
|
||||
}
|
||||
|
||||
int32_t mz_stream_buffered_is_open(void *stream)
|
||||
{
|
||||
return mz_stream_is_open(stream);
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
return mz_stream_is_open(buffered->stream.base);
|
||||
}
|
||||
|
||||
int32_t mz_stream_buffered_flush(void *stream, int32_t *written)
|
||||
static int32_t mz_stream_buffered_flush(void *stream, int32_t *written)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
int32_t total_bytes_written = 0;
|
||||
@@ -96,7 +97,7 @@ int32_t mz_stream_buffered_flush(void *stream, int32_t *written)
|
||||
|
||||
buffered->writebuf_misses += 1;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "write flush [%d:%d len %d]\n",
|
||||
mz_stream_buffered_print(stream, "write flush [%d:%d len %d]\n",
|
||||
bytes_to_write, bytes_left_to_write, buffered->writebuf_len);
|
||||
|
||||
total_bytes_written += bytes_written;
|
||||
@@ -120,10 +121,10 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size)
|
||||
int32_t bytes_left_to_read = size;
|
||||
int32_t bytes_read = 0;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "read [size %ld pos %lld]\n", size, buffered->position);
|
||||
mz_stream_buffered_print(stream, "read [size %ld pos %lld]\n", size, buffered->position);
|
||||
|
||||
if (buffered->writebuf_len > 0)
|
||||
mz_stream_buffered_print(opaque, stream, "switch from write to read, not yet supported [%lld]\n",
|
||||
mz_stream_buffered_print(stream, "switch from write to read, not yet supported [%lld]\n",
|
||||
buffered->position);
|
||||
|
||||
while (bytes_left_to_read > 0)
|
||||
@@ -137,15 +138,15 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size)
|
||||
}
|
||||
|
||||
bytes_to_read = sizeof(buffered->readbuf) - (buffered->readbuf_len - buffered->readbuf_pos);
|
||||
|
||||
if (mz_stream_read(buffered->stream.base, buffered->readbuf + buffered->readbuf_pos, bytes_to_read) != bytes_to_read)
|
||||
return 0;
|
||||
bytes_read = mz_stream_read(buffered->stream.base, buffered->readbuf + buffered->readbuf_pos, bytes_to_read);
|
||||
if (bytes_read < 0)
|
||||
return bytes_read;
|
||||
|
||||
buffered->readbuf_misses += 1;
|
||||
buffered->readbuf_len += bytes_read;
|
||||
buffered->position += bytes_read;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "filled [read %d/%d buf %d:%d pos %lld]\n",
|
||||
mz_stream_buffered_print(stream, "filled [read %d/%d buf %d:%d pos %lld]\n",
|
||||
bytes_read, bytes_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position);
|
||||
|
||||
if (bytes_read == 0)
|
||||
@@ -166,7 +167,7 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size)
|
||||
buffered->readbuf_hits += 1;
|
||||
buffered->readbuf_pos += bytes_to_copy;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "emptied [copied %d remaining %d buf %d:%d pos %lld]\n",
|
||||
mz_stream_buffered_print(stream, "emptied [copied %d remaining %d buf %d:%d pos %lld]\n",
|
||||
bytes_to_copy, bytes_left_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position);
|
||||
}
|
||||
}
|
||||
@@ -184,7 +185,7 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size)
|
||||
int32_t bytes_flushed = 0;
|
||||
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "write [size %ld len %d pos %lld]\n",
|
||||
mz_stream_buffered_print(stream, "write [size %ld len %d pos %lld]\n",
|
||||
size, buffered->writebuf_len, buffered->position);
|
||||
|
||||
if (buffered->readbuf_len > 0)
|
||||
@@ -195,7 +196,7 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size)
|
||||
buffered->readbuf_len = 0;
|
||||
buffered->readbuf_pos = 0;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "switch from read to write [%lld]\n", buffered->position);
|
||||
mz_stream_buffered_print(stream, "switch from read to write [%lld]\n", buffered->position);
|
||||
|
||||
if (mz_stream_seek(buffered->stream.base, buffered->position, MZ_SEEK_SET) != MZ_OK)
|
||||
return MZ_STREAM_ERROR;
|
||||
@@ -222,7 +223,7 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size)
|
||||
|
||||
memcpy(buffered->writebuf + buffered->writebuf_pos, (char *)buf + (bytes_to_write - bytes_left_to_write), bytes_to_copy);
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "write copy [remaining %d write %d:%d len %d]\n",
|
||||
mz_stream_buffered_print(stream, "write copy [remaining %d write %d:%d len %d]\n",
|
||||
bytes_to_copy, bytes_to_write, bytes_left_to_write, buffered->writebuf_len);
|
||||
|
||||
bytes_left_to_write -= bytes_to_copy;
|
||||
@@ -236,12 +237,14 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size)
|
||||
return size - bytes_left_to_write;
|
||||
}
|
||||
|
||||
int64_t mz_stream_buffered_tellinternal(void *stream, uint64_t position)
|
||||
int64_t mz_stream_buffered_tell(void *stream)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
int64_t position = mz_stream_tell(buffered->stream.base);
|
||||
|
||||
buffered->position = position;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "tell [pos %llu readpos %d writepos %d err %d]\n",
|
||||
mz_stream_buffered_print(stream, "tell [pos %llu readpos %d writepos %d err %d]\n",
|
||||
buffered->position, buffered->readbuf_pos, buffered->writebuf_pos, errno);
|
||||
|
||||
if (buffered->readbuf_len > 0)
|
||||
@@ -251,19 +254,12 @@ int64_t mz_stream_buffered_tellinternal(void *stream, uint64_t position)
|
||||
return position;
|
||||
}
|
||||
|
||||
int64_t mz_stream_buffered_tell(void *stream)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
int64_t position = mz_stream_tell(buffered->stream.base);
|
||||
return mz_stream_buffered_tellinternal(stream, position);
|
||||
}
|
||||
|
||||
int mz_stream_buffered_seekinternal(void *stream, int64_t offset, int32_t origin)
|
||||
int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
int32_t bytes_flushed = 0;
|
||||
|
||||
mz_stream_buffered_print(opaque, stream, "seek [origin %d offset %llu pos %lld]\n", origin, offset, buffered->position);
|
||||
mz_stream_buffered_print(stream, "seek [origin %d offset %llu pos %lld]\n", origin, offset, buffered->position);
|
||||
|
||||
switch (origin)
|
||||
{
|
||||
@@ -332,14 +328,7 @@ int mz_stream_buffered_seekinternal(void *stream, int64_t offset, int32_t origin
|
||||
buffered->readbuf_pos = 0;
|
||||
buffered->writebuf_len = 0;
|
||||
buffered->writebuf_pos = 0;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
|
||||
int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
if (mz_stream_buffered_seekinternal(stream, offset, origin) != MZ_OK)
|
||||
return MZ_STREAM_ERROR;
|
||||
return mz_stream_seek(buffered->stream.base, offset, origin);
|
||||
}
|
||||
|
||||
@@ -349,23 +338,23 @@ int32_t mz_stream_buffered_close(void *stream)
|
||||
int32_t bytes_flushed = 0;
|
||||
|
||||
mz_stream_buffered_flush(stream, &bytes_flushed);
|
||||
mz_stream_buffered_print(opaque, stream, "close\n");
|
||||
mz_stream_buffered_print(stream, "close\n");
|
||||
|
||||
if (buffered->readbuf_hits + buffered->readbuf_misses > 0)
|
||||
mz_stream_buffered_print(opaque, stream, "read efficency %.02f%%\n",
|
||||
mz_stream_buffered_print(stream, "read efficency %.02f%%\n",
|
||||
(buffered->readbuf_hits / ((float)buffered->readbuf_hits + buffered->readbuf_misses)) * 100);
|
||||
|
||||
if (buffered->writebuf_hits + buffered->writebuf_misses > 0)
|
||||
mz_stream_buffered_print(opaque, stream, "write efficency %.02f%%\n",
|
||||
mz_stream_buffered_print(stream, "write efficency %.02f%%\n",
|
||||
(buffered->writebuf_hits / ((float)buffered->writebuf_hits + buffered->writebuf_misses)) * 100);
|
||||
|
||||
return mz_stream_close(&buffered->stream.base);
|
||||
return mz_stream_close(buffered->stream.base);
|
||||
}
|
||||
|
||||
int32_t mz_stream_buffered_error(void *stream)
|
||||
{
|
||||
mz_stream_buffered *buffered = (mz_stream_buffered *)stream;
|
||||
return mz_stream_error(&buffered->stream.base);
|
||||
return mz_stream_error(buffered->stream.base);
|
||||
}
|
||||
|
||||
void *mz_stream_buffered_create(void **stream)
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
/* mz_strm_buf.h -- Stream for buffering reads/writes
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
This version of ioapi is designed to buffer IO.
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
+9
-7
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_bzip.c -- Stream for bzip inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as bzip.
|
||||
@@ -190,7 +190,7 @@ int32_t mz_stream_bzip_read(void *stream, void *buf, int32_t size)
|
||||
return total_out;
|
||||
}
|
||||
|
||||
int32_t mz_stream_bzip_flush(void *stream)
|
||||
static int32_t mz_stream_bzip_flush(void *stream)
|
||||
{
|
||||
mz_stream_bzip *bzip = (mz_stream_bzip *)stream;
|
||||
if (mz_stream_write(bzip->stream.base, bzip->buffer, bzip->buffer_len) != bzip->buffer_len)
|
||||
@@ -198,7 +198,7 @@ int32_t mz_stream_bzip_flush(void *stream)
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_bzip_compress(void *stream, int flush)
|
||||
static int32_t mz_stream_bzip_compress(void *stream, int flush)
|
||||
{
|
||||
mz_stream_bzip *bzip = (mz_stream_bzip *)stream;
|
||||
uint64_t total_out_before = 0;
|
||||
@@ -232,14 +232,16 @@ int32_t mz_stream_bzip_compress(void *stream, int flush)
|
||||
|
||||
out_bytes = (uint32_t)(total_out_after - total_out_before);
|
||||
|
||||
bzip->buffer_len += out_bytes;
|
||||
bzip->total_out += out_bytes;
|
||||
|
||||
if (err == BZ_STREAM_END)
|
||||
break;
|
||||
if (err < 0)
|
||||
{
|
||||
bzip->error = err;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
|
||||
bzip->buffer_len += out_bytes;
|
||||
bzip->total_out += out_bytes;
|
||||
}
|
||||
while ((bzip->bzstream.avail_in > 0) || (flush == BZ_FINISH && err == BZ_FINISH_OK));
|
||||
|
||||
|
||||
+4
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_bzip.h -- Stream for bzip inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -37,6 +37,8 @@ void mz_stream_bzip_delete(void **stream);
|
||||
|
||||
void* mz_stream_bzip_get_interface(void);
|
||||
|
||||
void bz_internal_error(int errcode);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+13
-7
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_crypt.c -- Code for traditional PKWARE encryption
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
Modifications for Info-ZIP crypting
|
||||
@@ -80,7 +80,7 @@ typedef struct mz_stream_crypt_s {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
uint8_t mz_stream_crypt_decrypt_byte(uint32_t *keys)
|
||||
static uint8_t mz_stream_crypt_decrypt_byte(uint32_t *keys)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
@@ -90,7 +90,7 @@ uint8_t mz_stream_crypt_decrypt_byte(uint32_t *keys)
|
||||
return (uint8_t)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
uint8_t mz_stream_crypt_update_keys(uint32_t *keys, const z_crc_t *crc_32_tab, int32_t c)
|
||||
static uint8_t mz_stream_crypt_update_keys(uint32_t *keys, const z_crc_t *crc_32_tab, int32_t c)
|
||||
{
|
||||
#define CRC32(c, b) ((*(crc_32_tab+(((uint32_t)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
@@ -104,7 +104,7 @@ uint8_t mz_stream_crypt_update_keys(uint32_t *keys, const z_crc_t *crc_32_tab, i
|
||||
return (uint8_t)c;
|
||||
}
|
||||
|
||||
void mz_stream_crypt_init_keys(const char *password, uint32_t *keys, const z_crc_t *crc_32_tab)
|
||||
static void mz_stream_crypt_init_keys(const char *password, uint32_t *keys, const z_crc_t *crc_32_tab)
|
||||
{
|
||||
*(keys+0) = 305419896L;
|
||||
*(keys+1) = 591751049L;
|
||||
@@ -124,6 +124,8 @@ int32_t mz_stream_crypt_open(void *stream, const char *path, int32_t mode)
|
||||
mz_stream_crypt *crypt = (mz_stream_crypt *)stream;
|
||||
uint16_t t = 0;
|
||||
int16_t i = 0;
|
||||
uint8_t verify1 = 0;
|
||||
uint8_t verify2 = 0;
|
||||
uint8_t header[RAND_HEAD_LEN];
|
||||
const char *password = path;
|
||||
|
||||
@@ -170,8 +172,12 @@ int32_t mz_stream_crypt_open(void *stream, const char *path, int32_t mode)
|
||||
for (i = 0; i < RAND_HEAD_LEN - 2; i++)
|
||||
header[i] = (uint8_t)zdecode(crypt->keys, crypt->crc_32_tab, header[i]);
|
||||
|
||||
crypt->verify1 = (uint8_t)zdecode(crypt->keys, crypt->crc_32_tab, header[i++]);
|
||||
crypt->verify2 = (uint8_t)zdecode(crypt->keys, crypt->crc_32_tab, header[i++]);
|
||||
verify1 = (uint8_t)zdecode(crypt->keys, crypt->crc_32_tab, header[i++]);
|
||||
verify2 = (uint8_t)zdecode(crypt->keys, crypt->crc_32_tab, header[i++]);
|
||||
|
||||
// Older versions used 2 byte check, newer versions use 1 byte check.
|
||||
if ((verify2 != 0) && (verify2 != crypt->verify2))
|
||||
return MZ_PASSWORD_ERROR;
|
||||
|
||||
crypt->total_in += RAND_HEAD_LEN;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_crypt.h -- Code for traditional PKWARE encryption
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
Modifications for Info-ZIP crypting
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_lzma.c -- Stream for lzma inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as lzma.
|
||||
@@ -207,7 +207,7 @@ int32_t mz_stream_lzma_read(void *stream, void *buf, int32_t size)
|
||||
return total_out;
|
||||
}
|
||||
|
||||
int32_t mz_stream_lzma_flush(void *stream)
|
||||
static int32_t mz_stream_lzma_flush(void *stream)
|
||||
{
|
||||
mz_stream_lzma *lzma = (mz_stream_lzma *)stream;
|
||||
if (mz_stream_write(lzma->stream.base, lzma->buffer, lzma->buffer_len) != lzma->buffer_len)
|
||||
@@ -215,7 +215,7 @@ int32_t mz_stream_lzma_flush(void *stream)
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_lzma_code(void *stream, int32_t flush)
|
||||
static int32_t mz_stream_lzma_code(void *stream, int32_t flush)
|
||||
{
|
||||
mz_stream_lzma *lzma = (mz_stream_lzma *)stream;
|
||||
uint64_t total_out_before = 0;
|
||||
@@ -383,7 +383,7 @@ void *mz_stream_lzma_get_interface(void)
|
||||
return (void *)&mz_stream_lzma_vtbl;
|
||||
}
|
||||
|
||||
int32_t mz_stream_lzma_crc32(int32_t value, const void *buf, int32_t size)
|
||||
static int32_t mz_stream_lzma_crc32(int32_t value, const void *buf, int32_t size)
|
||||
{
|
||||
return lzma_crc32(buf, size, value);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_lzma.h -- Stream for lzma inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as lzma.
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* mz_strm_mem.c -- Stream for memory access
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
This interface is designed to access memory rather than files.
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
Based on Unzip ioapi.c version 0.22, May 19th, 2003
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2003 Justin Fletcher
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_mem.h -- Stream for memory access
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2003 Justin Fletcher
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_posix.c -- Stream for filesystem access for posix/linux
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
@@ -113,9 +113,9 @@ int32_t mz_stream_posix_read(void *stream, void *buf, int32_t size)
|
||||
{
|
||||
mz_stream_posix *posix = (mz_stream_posix*)stream;
|
||||
int32_t read = (int32_t)fread(buf, 1, (size_t)size, posix->handle);
|
||||
if (read < 0)
|
||||
if (read < size && ferror(posix->handle))
|
||||
{
|
||||
posix->error = ferror(posix->handle);
|
||||
posix->error = errno;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
return read;
|
||||
@@ -125,9 +125,9 @@ int32_t mz_stream_posix_write(void *stream, const void *buf, int32_t size)
|
||||
{
|
||||
mz_stream_posix *posix = (mz_stream_posix*)stream;
|
||||
int32_t written = (int32_t)fwrite(buf, 1, (size_t)size, posix->handle);
|
||||
if (written < 0)
|
||||
if (written < size && ferror(posix->handle))
|
||||
{
|
||||
posix->error = ferror(posix->handle);
|
||||
posix->error = errno;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
return written;
|
||||
@@ -139,7 +139,7 @@ int64_t mz_stream_posix_tell(void *stream)
|
||||
int64_t position = ftello64(posix->handle);
|
||||
if (position == -1)
|
||||
{
|
||||
posix->error = ferror(posix->handle);
|
||||
posix->error = errno;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
return position;
|
||||
@@ -167,7 +167,7 @@ int32_t mz_stream_posix_seek(void *stream, int64_t offset, int32_t origin)
|
||||
|
||||
if (fseeko64(posix->handle, offset, fseek_origin) != 0)
|
||||
{
|
||||
posix->error = ferror(posix->handle);
|
||||
posix->error = errno;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_posix.h -- Stream for filesystem access for posix/linux
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
|
||||
+9
-6
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_split.c -- Stream for split files
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
#define MZ_ZIP_MAGIC_DISKHEADER (0x08074b50)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
mz_stream_vtbl mz_stream_split_vtbl = {
|
||||
@@ -62,14 +66,13 @@ typedef struct mz_stream_split_s {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
|
||||
static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
|
||||
{
|
||||
mz_stream_split *split = (mz_stream_split *)stream;
|
||||
uint32_t magic = 0;
|
||||
int32_t i = 0;
|
||||
int32_t err = MZ_OK;
|
||||
int16_t disk_part = 0;
|
||||
int16_t read_disk_part = 0;
|
||||
|
||||
|
||||
// Check if we are reading or writing a disk part or the cd disk
|
||||
@@ -136,7 +139,7 @@ int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t mz_stream_split_close_disk(void *stream)
|
||||
static int32_t mz_stream_split_close_disk(void *stream)
|
||||
{
|
||||
mz_stream_split *split = (mz_stream_split *)stream;
|
||||
|
||||
@@ -146,7 +149,7 @@ int32_t mz_stream_split_close_disk(void *stream)
|
||||
return mz_stream_close(split->stream.base);
|
||||
}
|
||||
|
||||
int32_t mz_stream_split_goto_disk(void *stream, int32_t number_disk)
|
||||
static int32_t mz_stream_split_goto_disk(void *stream, int32_t number_disk)
|
||||
{
|
||||
mz_stream_split *split = (mz_stream_split *)stream;
|
||||
int32_t err = MZ_OK;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_split.h -- Stream for split files
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_win32.c -- Stream for filesystem access for windows
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_sstrm_win32.h -- Stream for filesystem access for windows
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
|
||||
+17
-10
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_zlib.c -- Stream for zlib inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
@@ -195,7 +195,7 @@ int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size)
|
||||
return total_out;
|
||||
}
|
||||
|
||||
int32_t mz_stream_zlib_flush(void *stream)
|
||||
static int32_t mz_stream_zlib_flush(void *stream)
|
||||
{
|
||||
mz_stream_zlib *zlib = (mz_stream_zlib *)stream;
|
||||
if (mz_stream_write(zlib->stream.base, zlib->buffer, zlib->buffer_len) != zlib->buffer_len)
|
||||
@@ -203,7 +203,7 @@ int32_t mz_stream_zlib_flush(void *stream)
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_zlib_deflate(void *stream, int flush)
|
||||
static int32_t mz_stream_zlib_deflate(void *stream, int flush)
|
||||
{
|
||||
mz_stream_zlib *zlib = (mz_stream_zlib *)stream;
|
||||
uint64_t total_out_before = 0;
|
||||
@@ -234,16 +234,18 @@ int32_t mz_stream_zlib_deflate(void *stream, int flush)
|
||||
|
||||
out_bytes = (uint32_t)(total_out_after - total_out_before);
|
||||
|
||||
if (err != Z_OK && err != Z_STREAM_END)
|
||||
zlib->buffer_len += out_bytes;
|
||||
zlib->total_out += out_bytes;
|
||||
|
||||
if (err == Z_STREAM_END)
|
||||
break;
|
||||
if (err != Z_OK)
|
||||
{
|
||||
zlib->error = err;
|
||||
return MZ_STREAM_ERROR;
|
||||
}
|
||||
|
||||
zlib->buffer_len += out_bytes;
|
||||
zlib->total_out += out_bytes;
|
||||
}
|
||||
while (zlib->zstream.avail_in > 0);
|
||||
while ((zlib->zstream.avail_in > 0) || (flush == Z_FINISH && err == Z_OK));
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
@@ -369,7 +371,12 @@ void *mz_stream_zlib_get_interface(void)
|
||||
return (void *)&mz_stream_zlib_vtbl;
|
||||
}
|
||||
|
||||
static int32_t mz_stream_zlib_crc32(int32_t value, const void *buf, int32_t size)
|
||||
{
|
||||
return crc32(value, buf, size);
|
||||
}
|
||||
|
||||
void *mz_stream_zlib_get_crc32_update(void)
|
||||
{
|
||||
return (void *)crc32;
|
||||
return (void *)mz_stream_zlib_crc32;
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_strm_zlib.h -- Stream for zlib inflate/deflate
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
|
||||
Executable → Regular
+35
-35
@@ -1,9 +1,8 @@
|
||||
/* zip.c -- Zip manipulation
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2017 Nathan Moinvaziri
|
||||
Modifications for AES, PKWARE disk spanning
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
@@ -463,9 +462,8 @@ extern void* mz_zip_open(void *stream, int32_t mode)
|
||||
memset(zip, 0, sizeof(mz_zip));
|
||||
|
||||
zip->stream = stream;
|
||||
zip->open_mode = mode;
|
||||
|
||||
if (zip->open_mode & MZ_OPEN_MODE_WRITE)
|
||||
if (mode & MZ_OPEN_MODE_WRITE)
|
||||
{
|
||||
mz_stream_mem_create(&zip->cd_mem_stream);
|
||||
mz_stream_mem_open(zip->cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE);
|
||||
@@ -477,7 +475,7 @@ extern void* mz_zip_open(void *stream, int32_t mode)
|
||||
zip->cd_stream = stream;
|
||||
}
|
||||
|
||||
if ((zip->open_mode & MZ_OPEN_MODE_READ) || (mode & MZ_OPEN_MODE_APPEND))
|
||||
if ((mode & MZ_OPEN_MODE_READ) || (mode & MZ_OPEN_MODE_APPEND))
|
||||
{
|
||||
err = mz_zip_read_cd(zip);
|
||||
|
||||
@@ -514,23 +512,12 @@ extern void* mz_zip_open(void *stream, int32_t mode)
|
||||
|
||||
if (err != MZ_OK)
|
||||
{
|
||||
if (zip->file_info_stream != NULL)
|
||||
mz_stream_mem_delete(&zip->file_info_stream);
|
||||
if (zip->local_file_info_stream != NULL)
|
||||
mz_stream_mem_delete(&zip->local_file_info_stream);
|
||||
if (zip->cd_mem_stream != NULL)
|
||||
{
|
||||
mz_stream_close(zip->cd_mem_stream);
|
||||
mz_stream_delete(&zip->cd_mem_stream);
|
||||
}
|
||||
|
||||
if (zip->comment)
|
||||
free(zip->comment);
|
||||
|
||||
free(zip);
|
||||
mz_zip_close(zip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zip->open_mode = mode;
|
||||
|
||||
return zip;
|
||||
}
|
||||
|
||||
@@ -558,10 +545,16 @@ extern int32_t mz_zip_close(void *handle)
|
||||
mz_stream_delete(&zip->cd_mem_stream);
|
||||
}
|
||||
|
||||
mz_stream_mem_close(zip->file_info_stream);
|
||||
mz_stream_mem_delete(&zip->file_info_stream);
|
||||
mz_stream_mem_close(zip->local_file_info_stream);
|
||||
mz_stream_mem_delete(&zip->local_file_info_stream);
|
||||
if (zip->file_info_stream != NULL)
|
||||
{
|
||||
mz_stream_mem_close(zip->file_info_stream);
|
||||
mz_stream_mem_delete(&zip->file_info_stream);
|
||||
}
|
||||
if (zip->local_file_info_stream != NULL)
|
||||
{
|
||||
mz_stream_mem_close(zip->local_file_info_stream);
|
||||
mz_stream_mem_delete(&zip->local_file_info_stream);
|
||||
}
|
||||
|
||||
if (zip->comment)
|
||||
free(zip->comment);
|
||||
@@ -851,7 +844,6 @@ static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file
|
||||
|
||||
static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_file *file_info)
|
||||
{
|
||||
struct tm *local_time = NULL;
|
||||
uint64_t ntfs_time = 0;
|
||||
uint32_t reserved = 0;
|
||||
uint32_t dos_date = 0;
|
||||
@@ -1102,17 +1094,26 @@ static int32_t mz_zip_entry_open_int(void *handle, int16_t compression_method, i
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_CRYPT
|
||||
uint32_t dos_date = 0;
|
||||
uint8_t verify1 = 0;
|
||||
uint8_t verify2 = 0;
|
||||
|
||||
// Info-ZIP modification to ZipCrypto format:
|
||||
// If bit 3 of the general purpose bit flag is set, it uses high byte of 16-bit File Time.
|
||||
|
||||
dos_date = mz_zip_time_t_to_dos_date(zip->file_info.modified_date);
|
||||
if (zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR)
|
||||
{
|
||||
uint32_t dos_date = 0;
|
||||
|
||||
verify1 = (uint8_t)((dos_date >> 16) & 0xff);
|
||||
verify2 = (uint8_t)((dos_date >> 8) & 0xff);
|
||||
dos_date = mz_zip_time_t_to_dos_date(zip->file_info.modified_date);
|
||||
|
||||
verify1 = (uint8_t)((dos_date >> 16) & 0xff);
|
||||
verify2 = (uint8_t)((dos_date >> 8) & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
verify1 = (uint8_t)((zip->file_info.crc >> 16) & 0xff);
|
||||
verify2 = (uint8_t)((zip->file_info.crc >> 24) & 0xff);
|
||||
}
|
||||
|
||||
mz_stream_crypt_create(&zip->crypt_stream);
|
||||
mz_stream_crypt_set_password(zip->crypt_stream, password);
|
||||
@@ -1315,7 +1316,7 @@ extern int32_t mz_zip_entry_read(void *handle, void *buf, uint32_t len)
|
||||
return MZ_PARAM_ERROR;
|
||||
if (len > UINT16_MAX) // Zlib limitation
|
||||
return MZ_PARAM_ERROR;
|
||||
if (len == 0)
|
||||
if (len == 0 || zip->file_info.uncompressed_size == 0)
|
||||
return 0;
|
||||
read = mz_stream_read(zip->crc32_stream, buf, len);
|
||||
if (read > 0)
|
||||
@@ -1404,16 +1405,16 @@ extern int32_t mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_size,
|
||||
if (err == MZ_OK)
|
||||
{
|
||||
if (zip->file_info.uncompressed_size <= UINT32_MAX)
|
||||
err = mz_stream_write_uint64(zip->stream, compressed_size);
|
||||
else
|
||||
err = mz_stream_write_uint32(zip->stream, (uint32_t)compressed_size);
|
||||
else
|
||||
err = mz_stream_write_uint64(zip->stream, compressed_size);
|
||||
}
|
||||
if (err == MZ_OK)
|
||||
{
|
||||
if (zip->file_info.uncompressed_size <= UINT32_MAX)
|
||||
err = mz_stream_write_uint64(zip->stream, uncompressed_size);
|
||||
else
|
||||
err = mz_stream_write_uint32(zip->stream, (uint32_t)uncompressed_size);
|
||||
else
|
||||
err = mz_stream_write_uint64(zip->stream, uncompressed_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1589,7 +1590,6 @@ uint32_t mz_zip_time_t_to_dos_date(time_t unix_time)
|
||||
uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm)
|
||||
{
|
||||
struct tm fixed_tm = { 0 };
|
||||
uint32_t dos_date = 0;
|
||||
|
||||
// Years supported:
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/* mz_zip.h -- Zip manipulation
|
||||
Version 2.2.4, November 15th, 2017
|
||||
Version 2.2.6, January 6th, 2018
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
Copyright (C) 2010-2018 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
|
||||
+2
-2
@@ -151,7 +151,7 @@ void test_compress(char *method, mz_stream_create_cb create_compress)
|
||||
|
||||
mz_stream_delete(&deflate_stream);
|
||||
|
||||
printf("%s compressed from %d to %d\n", filename, (uint32_t)total_in, (uint32_t)total_out);
|
||||
printf("%s compressed from %u to %u\n", filename, (uint32_t)total_in, (uint32_t)total_out);
|
||||
|
||||
mz_stream_os_close(out_stream);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void test_compress(char *method, mz_stream_create_cb create_compress)
|
||||
|
||||
mz_stream_os_close(in_stream);
|
||||
|
||||
printf("%s uncompressed from %d to %d\n", filename, (uint32_t)total_in, (uint32_t)total_out);
|
||||
printf("%s uncompressed from %u to %u\n", filename, (uint32_t)total_in, (uint32_t)total_out);
|
||||
}
|
||||
|
||||
mz_stream_os_delete(&in_stream);
|
||||
|
||||
@@ -199,3 +199,4 @@ sfx_zip_test()
|
||||
compression_method_tests()
|
||||
encryption_tests()
|
||||
compression_method_tests('Disk Span', '-k 1024', '')
|
||||
compression_method_tests('Buffered', '-u', '-u')
|
||||
|
||||
Reference in New Issue
Block a user