mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Version 2.8.9.
This commit is contained in:
parent
84498c7601
commit
32fd805440
@ -34,7 +34,7 @@ endif()
|
||||
enable_language(C)
|
||||
|
||||
# Minizip library version
|
||||
set(VERSION "2.8.8")
|
||||
set(VERSION "2.8.9")
|
||||
|
||||
# Minizip api version
|
||||
set(SOVERSION "2.5")
|
||||
|
@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Minizip'
|
||||
s.version = '2.8.8'
|
||||
s.version = '2.8.9'
|
||||
s.license = 'zlib'
|
||||
s.summary = 'Minizip contrib in zlib with the latest bug fixes and advanced features'
|
||||
s.description = <<-DESC
|
||||
|
@ -1,6 +1,6 @@
|
||||
# minizip 2.8.8
|
||||
# minizip 2.8.9
|
||||
|
||||
minizip is a zip manipulation library written in C that is supported on Windows, macOS, and Linux.
|
||||
minizip is a zip manipulation library written in C that is supported on Windows, macOS, and Linux.
|
||||
|
||||
[](https://github.com/nmoinvaz/minizip/blob/master/LICENSE)
|
||||
[](https://lgtm.com/projects/g/nmoinvaz/minizip/context:cpp)
|
||||
@ -119,6 +119,6 @@ cmake --build .
|
||||
|
||||
Thanks go out to all the people who have taken the time to contribute code reviews, testing and/or patches. This project would not have been as good without you.
|
||||
|
||||
Thanks to [Gilles Vollant](https://www.winimage.com/zLibDll/minizip.html) on which this work is originally based on.
|
||||
Thanks to [Gilles Vollant](https://www.winimage.com/zLibDll/minizip.html) on which this work is originally based on.
|
||||
|
||||
The [ZIP format](https://github.com/nmoinvaz/minizip/blob/master/doc/appnote.txt) was defined by Phil Katz of PKWARE.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* minigzip.c
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
22
minizip.c
22
minizip.c
@ -1,5 +1,5 @@
|
||||
/* minizip.c
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -183,7 +183,7 @@ int32_t minizip_list(const char *path)
|
||||
/* Print entry information */
|
||||
printf("%12"PRId64" %12"PRId64" %3"PRIu32"%% %6s%c %8"PRIx32" %2.2"PRIu32\
|
||||
"-%2.2"PRIu32"-%2.2"PRIu32" %2.2"PRIu32":%2.2"PRIu32" %8.8"PRIx32" %s\n",
|
||||
file_info->compressed_size, file_info->uncompressed_size, ratio,
|
||||
file_info->compressed_size, file_info->uncompressed_size, ratio,
|
||||
string_method, crypt, file_info->external_fa,
|
||||
(uint32_t)tmu_date.tm_mon + 1, (uint32_t)tmu_date.tm_mday,
|
||||
(uint32_t)tmu_date.tm_year % 100,
|
||||
@ -214,7 +214,7 @@ int32_t minizip_add_entry_cb(void *handle, void *userdata, mz_zip_file *file_inf
|
||||
{
|
||||
MZ_UNUSED(handle);
|
||||
MZ_UNUSED(userdata);
|
||||
|
||||
|
||||
/* Print the current file we are trying to compress */
|
||||
printf("Adding %s\n", file_info->filename);
|
||||
return MZ_OK;
|
||||
@ -227,7 +227,7 @@ int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_
|
||||
uint8_t raw = 0;
|
||||
|
||||
MZ_UNUSED(userdata);
|
||||
|
||||
|
||||
mz_zip_writer_get_raw(handle, &raw);
|
||||
|
||||
if (raw && file_info->compressed_size > 0)
|
||||
@ -237,7 +237,7 @@ int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_
|
||||
|
||||
/* Print the progress of the current compress operation */
|
||||
if (options->verbose)
|
||||
printf("%s - %"PRId64" / %"PRId64" (%.02f%%)\n", file_info->filename, position,
|
||||
printf("%s - %"PRId64" / %"PRId64" (%.02f%%)\n", file_info->filename, position,
|
||||
file_info->uncompressed_size, progress);
|
||||
return MZ_OK;
|
||||
}
|
||||
@ -247,7 +247,7 @@ int32_t minizip_add_overwrite_cb(void *handle, void *userdata, const char *path)
|
||||
minizip_opt *options = (minizip_opt *)userdata;
|
||||
|
||||
MZ_UNUSED(handle);
|
||||
|
||||
|
||||
if (options->overwrite == 0)
|
||||
{
|
||||
/* If ask the user what to do because append and overwrite args not set */
|
||||
@ -340,7 +340,7 @@ int32_t minizip_extract_entry_cb(void *handle, void *userdata, mz_zip_file *file
|
||||
MZ_UNUSED(handle);
|
||||
MZ_UNUSED(userdata);
|
||||
MZ_UNUSED(path);
|
||||
|
||||
|
||||
/* Print the current entry extracting */
|
||||
printf("Extracting %s\n", file_info->filename);
|
||||
return MZ_OK;
|
||||
@ -353,7 +353,7 @@ int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *f
|
||||
uint8_t raw = 0;
|
||||
|
||||
MZ_UNUSED(userdata);
|
||||
|
||||
|
||||
mz_zip_reader_get_raw(handle, &raw);
|
||||
|
||||
if (raw && file_info->compressed_size > 0)
|
||||
@ -363,7 +363,7 @@ int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *f
|
||||
|
||||
/* Print the progress of the current extraction */
|
||||
if (options->verbose)
|
||||
printf("%s - %"PRId64" / %"PRId64" (%.02f%%)\n", file_info->filename, position,
|
||||
printf("%s - %"PRId64" / %"PRId64" (%.02f%%)\n", file_info->filename, position,
|
||||
file_info->uncompressed_size, progress);
|
||||
|
||||
return MZ_OK;
|
||||
@ -375,7 +375,7 @@ int32_t minizip_extract_overwrite_cb(void *handle, void *userdata, mz_zip_file *
|
||||
|
||||
MZ_UNUSED(handle);
|
||||
MZ_UNUSED(file_info);
|
||||
|
||||
|
||||
/* Verify if we want to overwrite current entry on disk */
|
||||
if (options->overwrite == 0)
|
||||
{
|
||||
@ -718,7 +718,7 @@ int main(int argc, const char *argv[])
|
||||
path_arg = i;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
if (err == MZ_SUPPORT_ERROR)
|
||||
{
|
||||
printf("Feature not supported\n");
|
||||
|
10
mz.h
10
mz.h
@ -1,5 +1,5 @@
|
||||
/* mz.h -- Errors codes, zip flags and magic
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -15,7 +15,7 @@
|
||||
/***************************************************************************/
|
||||
|
||||
/* MZ_VERSION */
|
||||
#define MZ_VERSION ("2.8.8")
|
||||
#define MZ_VERSION ("2.8.9")
|
||||
|
||||
/* MZ_ERROR */
|
||||
#define MZ_OK (0) /* zlib */
|
||||
@ -230,7 +230,7 @@ typedef unsigned long long uint64_t;
|
||||
#ifndef INT16_MAX
|
||||
# define INT16_MAX 32767
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
#ifndef INT32_MAX
|
||||
# define INT32_MAX 2147483647L
|
||||
#endif
|
||||
#ifndef INT64_MAX
|
||||
@ -239,8 +239,8 @@ typedef unsigned long long uint64_t;
|
||||
#ifndef UINT16_MAX
|
||||
# define UINT16_MAX 65535U
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX 4294967295UL
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX 4294967295UL
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
# define UINT64_MAX 18446744073709551615ULL
|
||||
|
24
mz_compat.c
24
mz_compat.c
@ -1,5 +1,5 @@
|
||||
/* mz_compat.c -- Backwards compatible interface for older versions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -245,7 +245,7 @@ int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_filein
|
||||
|
||||
int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int raw)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local,
|
||||
@ -255,7 +255,7 @@ int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo
|
||||
|
||||
int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int raw, int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local,
|
||||
@ -274,7 +274,7 @@ int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *
|
||||
|
||||
int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int zip64)
|
||||
{
|
||||
return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local,
|
||||
@ -835,14 +835,14 @@ int unzGetFilePos(unzFile file, unz_file_pos *file_pos)
|
||||
{
|
||||
mz_compat *compat = (mz_compat *)file;
|
||||
int32_t offset = 0;
|
||||
|
||||
|
||||
if (compat == NULL || file_pos == NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
|
||||
offset = unzGetOffset(file);
|
||||
if (offset < 0)
|
||||
return offset;
|
||||
|
||||
|
||||
file_pos->pos_in_zip_directory = (uint32_t)offset;
|
||||
file_pos->num_of_file = (uint32_t)compat->entry_index;
|
||||
return MZ_OK;
|
||||
@ -866,14 +866,14 @@ int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
|
||||
{
|
||||
mz_compat *compat = (mz_compat *)file;
|
||||
int64_t offset = 0;
|
||||
|
||||
|
||||
if (compat == NULL || file_pos == NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
|
||||
offset = unzGetOffset64(file);
|
||||
if (offset < 0)
|
||||
return (int)offset;
|
||||
|
||||
|
||||
file_pos->pos_in_zip_directory = offset;
|
||||
file_pos->num_of_file = compat->entry_index;
|
||||
return UNZ_OK;
|
||||
@ -928,11 +928,11 @@ int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len)
|
||||
|
||||
if (compat == NULL || buf == NULL || len >= INT32_MAX)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
|
||||
err = mz_zip_entry_get_local_info(compat->handle, &file_info);
|
||||
if (err != MZ_OK)
|
||||
return err;
|
||||
|
||||
|
||||
bytes_to_copy = (int32_t)len;
|
||||
if (bytes_to_copy > file_info->extrafield_size)
|
||||
bytes_to_copy = file_info->extrafield_size;
|
||||
|
14
mz_compat.h
14
mz_compat.h
@ -1,5 +1,5 @@
|
||||
/* mz_compat.h -- Backwards compatible interface for older versions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -111,15 +111,15 @@ ZEXPORT int zipOpenNewFileInZip(zipFile file, const char *filename, const zi
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level);
|
||||
ZEXPORT int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int raw);
|
||||
ZEXPORT int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level,
|
||||
int raw, int zip64);
|
||||
ZEXPORT int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
@ -251,7 +251,7 @@ typedef struct unz_file_info_s
|
||||
typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
|
||||
typedef int (*unzIteratorFunction)(unzFile file);
|
||||
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t comment_size);
|
||||
|
||||
/***************************************************************************/
|
||||
@ -279,10 +279,10 @@ ZEXPORT int unzCloseCurrentFile(unzFile file);
|
||||
|
||||
|
||||
ZEXPORT int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t comment_size);
|
||||
ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
uint16_t comment_size);
|
||||
|
||||
ZEXPORT int unzGoToFirstFile(unzFile file);
|
||||
|
81
mz_crypt.c
81
mz_crypt.c
@ -1,5 +1,5 @@
|
||||
/* mz_crypt.c -- Crypto/hash functions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -37,7 +37,7 @@
|
||||
# if (ZLIB_VERNUM < 0x1270)
|
||||
typedef unsigned long z_crc_t;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -49,48 +49,48 @@ uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size)
|
||||
return (uint32_t)lzma_crc32(buf, (size_t)size, (uint32_t)value);
|
||||
#else
|
||||
static uint32_t crc32_table[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
value = ~value;
|
||||
@ -102,7 +102,7 @@ uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size)
|
||||
buf += 1;
|
||||
size -= 1;
|
||||
}
|
||||
|
||||
|
||||
return ~value;
|
||||
#endif
|
||||
}
|
||||
@ -140,7 +140,7 @@ int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *sa
|
||||
err = mz_crypt_hmac_init(hmac2, password, password_length);
|
||||
if (err == MZ_OK)
|
||||
err = mz_crypt_hmac_update(hmac2, salt, salt_length);
|
||||
|
||||
|
||||
block_count = 1 + ((uint16_t)key_length - 1) / MZ_HASH_SHA1_SIZE;
|
||||
|
||||
for (i = 0; (err == MZ_OK) && (i < block_count); i += 1)
|
||||
@ -163,7 +163,7 @@ int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *sa
|
||||
err = mz_crypt_hmac_end(hmac3, uu, sizeof(uu));
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
|
||||
for(k = 0; k < MZ_HASH_SHA1_SIZE; k += 1)
|
||||
ux[k] ^= uu[k];
|
||||
|
||||
@ -182,7 +182,7 @@ int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *sa
|
||||
key[k++] = ux[j++];
|
||||
}
|
||||
|
||||
/* hmac3 uses the same provider as hmac2, so it must be deleted
|
||||
/* hmac3 uses the same provider as hmac2, so it must be deleted
|
||||
before the context is destroyed. */
|
||||
mz_crypt_hmac_delete(&hmac3);
|
||||
mz_crypt_hmac_delete(&hmac1);
|
||||
@ -193,4 +193,3 @@ int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *sa
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_crypt.h -- Crypto/hash functions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -20,7 +20,7 @@ extern "C" {
|
||||
|
||||
uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size);
|
||||
|
||||
int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt,
|
||||
int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt,
|
||||
int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length);
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_crypt_apple.c -- Crypto/hash functions for Apple
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -82,7 +82,7 @@ int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size)
|
||||
sha->error = CC_SHA1_Update(&sha->ctx1, buf, size);
|
||||
else
|
||||
sha->error = CC_SHA256_Update(&sha->ctx256, buf, size);
|
||||
|
||||
|
||||
if (!sha->error)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
@ -199,7 +199,7 @@ int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
aes->error = CCCryptorUpdate(aes->crypt, buf, size, buf, size, &data_moved);
|
||||
|
||||
|
||||
if (aes->error != kCCSuccess)
|
||||
return MZ_HASH_ERROR;
|
||||
|
||||
@ -305,10 +305,10 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length)
|
||||
{
|
||||
mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle;
|
||||
CCHmacAlgorithm algorithm = 0;
|
||||
|
||||
|
||||
if (hmac == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_hmac_reset(handle);
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
@ -407,7 +407,7 @@ void mz_crypt_hmac_delete(void **handle)
|
||||
/***************************************************************************/
|
||||
|
||||
#if !defined(MZ_ZIP_NO_SIGNING)
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size)
|
||||
{
|
||||
CFStringRef password_ref = NULL;
|
||||
@ -525,7 +525,7 @@ int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *si
|
||||
CFRelease(trust_policy);
|
||||
if (decoder)
|
||||
CFRelease(decoder);
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_crypt_brg.c -- Crypto/hash functions using Brian Gladman's library
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -20,7 +20,7 @@
|
||||
# include <sys/types.h>
|
||||
# ifndef __u_char_defined
|
||||
typedef unsigned char u_char;
|
||||
# endif
|
||||
# endif
|
||||
# include <bsd/stdlib.h> /* arc4random_buf */
|
||||
#endif
|
||||
|
||||
@ -243,7 +243,7 @@ int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_
|
||||
|
||||
if (aes == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
aes->error = aes_encrypt_key(key, key_length, &aes->encrypt_ctx);
|
||||
@ -260,7 +260,7 @@ int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_
|
||||
|
||||
if (aes == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
aes->error = aes_decrypt_key(key, key_length, &aes->decrypt_ctx);
|
||||
@ -325,14 +325,14 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_crypt_hmac_reset(handle);
|
||||
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
hmac_sha_begin(HMAC_SHA1, &hmac->ctx);
|
||||
else
|
||||
hmac_sha_begin(HMAC_SHA256, &hmac->ctx);
|
||||
|
||||
|
||||
hmac_sha_key(key, key_length, &hmac->ctx);
|
||||
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ void mz_crypt_hmac_delete(void **handle)
|
||||
/***************************************************************************/
|
||||
|
||||
#if !defined(MZ_ZIP_NO_SIGNING)
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size)
|
||||
{
|
||||
MZ_UNUSED(message);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_crypt_openssl.c -- Crypto/hash functions for OpenSSL
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -240,7 +240,7 @@ int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_
|
||||
|
||||
if (aes == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
key_bits = key_length * 8;
|
||||
@ -263,7 +263,7 @@ int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_
|
||||
|
||||
if (aes == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
key_bits = key_length * 8;
|
||||
@ -336,7 +336,7 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length)
|
||||
|
||||
if (hmac == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_hmac_reset(handle);
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
@ -462,7 +462,7 @@ void mz_crypt_hmac_delete(void **handle)
|
||||
/***************************************************************************/
|
||||
|
||||
#if !defined(MZ_ZIP_NO_SIGNING)
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size)
|
||||
{
|
||||
PKCS12 *p12 = NULL;
|
||||
@ -517,10 +517,10 @@ int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data
|
||||
|
||||
*signature_size = buf_mem->length;
|
||||
*signature = MZ_ALLOC(buf_mem->length);
|
||||
|
||||
|
||||
memcpy(*signature, buf_mem->data, buf_mem->length);
|
||||
}
|
||||
#if 0
|
||||
#if 0
|
||||
BIO *yy = BIO_new_file("xyz", "wb");
|
||||
BIO_write(yy, *signature, *signature_size);
|
||||
BIO_flush(yy);
|
||||
@ -587,7 +587,7 @@ int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *si
|
||||
BIO_free(yy);
|
||||
#endif
|
||||
|
||||
lookup = X509_STORE_add_lookup(cert_store, X509_LOOKUP_file());
|
||||
lookup = X509_STORE_add_lookup(cert_store, X509_LOOKUP_file());
|
||||
if (lookup != NULL)
|
||||
X509_LOOKUP_load_file(lookup, "cacert.pem", X509_FILETYPE_PEM);
|
||||
lookup = X509_STORE_add_lookup(cert_store, X509_LOOKUP_hash_dir());
|
||||
@ -633,7 +633,7 @@ int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *si
|
||||
if (err == MZ_OK)
|
||||
{
|
||||
/* Verify the message */
|
||||
if (((int32_t)buf_mem->length != message_size) ||
|
||||
if (((int32_t)buf_mem->length != message_size) ||
|
||||
(memcmp(buf_mem->data, message, message_size) != 0))
|
||||
err = MZ_SIGN_ERROR;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_crypt_win32.c -- Crypto/hash functions for Windows
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -252,9 +252,9 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
|
||||
if (aes == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_aes_reset(handle);
|
||||
|
||||
|
||||
if (key_length == MZ_AES_KEY_LENGTH(MZ_AES_ENCRYPTION_MODE_128))
|
||||
alg_id = CALG_AES_128;
|
||||
else if (key_length == MZ_AES_KEY_LENGTH(MZ_AES_ENCRYPTION_MODE_192))
|
||||
@ -263,7 +263,7 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
alg_id = CALG_AES_256;
|
||||
else
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
result = CryptAcquireContext(&aes->provider, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
if (result)
|
||||
{
|
||||
@ -399,9 +399,9 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length)
|
||||
|
||||
if (hmac == NULL || key == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_crypt_hmac_reset(handle);
|
||||
|
||||
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
alg_id = CALG_SHA1;
|
||||
else
|
||||
@ -409,7 +409,7 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length)
|
||||
|
||||
hmac->info.HashAlgid = alg_id;
|
||||
|
||||
result = CryptAcquireContext(&hmac->provider, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL,
|
||||
result = CryptAcquireContext(&hmac->provider, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
|
||||
if (!result)
|
||||
@ -560,7 +560,7 @@ void mz_crypt_hmac_delete(void **handle)
|
||||
/***************************************************************************/
|
||||
|
||||
#if !defined(MZ_ZIP_NO_SIGNING)
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size,
|
||||
const char *cert_pwd, uint8_t **signature, int32_t *signature_size)
|
||||
{
|
||||
CRYPT_SIGN_MESSAGE_PARA sign_params;
|
||||
@ -629,8 +629,8 @@ int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data
|
||||
timestamp_url_wide = mz_os_unicode_string_create(timestamp_url);
|
||||
if (timestamp_url_wide != NULL)
|
||||
{
|
||||
result = CryptRetrieveTimeStamp(timestamp_url_wide,
|
||||
TIMESTAMP_NO_AUTH_RETRIEVAL | TIMESTAMP_VERIFY_CONTEXT_SIGNATURE, 0, szOID_NIST_sha256,
|
||||
result = CryptRetrieveTimeStamp(timestamp_url_wide,
|
||||
TIMESTAMP_NO_AUTH_RETRIEVAL | TIMESTAMP_VERIFY_CONTEXT_SIGNATURE, 0, szOID_NIST_sha256,
|
||||
NULL, message, message_size, &ts_context, NULL, NULL);
|
||||
|
||||
mz_os_unicode_string_delete(×tamp_url_wide);
|
||||
@ -695,7 +695,7 @@ int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *si
|
||||
verify_params.hCryptProv = 0;
|
||||
verify_params.pfnGetSignerCertificate = NULL;
|
||||
verify_params.pvGetArg = NULL;
|
||||
|
||||
|
||||
result = CryptVerifyMessageSignature(&verify_params, 0, signature, signature_size,
|
||||
NULL, &decoded_size, NULL);
|
||||
|
||||
|
4
mz_os.c
4
mz_os.c
@ -1,5 +1,5 @@
|
||||
/* mz_os.c -- System functions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -58,7 +58,7 @@ int32_t mz_path_append_slash(char *path, int32_t max_path, char slash)
|
||||
}
|
||||
|
||||
int32_t mz_path_remove_slash(char *path)
|
||||
{
|
||||
{
|
||||
int32_t path_len = (int32_t)strlen(path);
|
||||
while (path_len > 0)
|
||||
{
|
||||
|
2
mz_os.h
2
mz_os.h
@ -1,5 +1,5 @@
|
||||
/* mz_os.h -- System functions
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_os_posix.c -- System functions for posix
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_os_win32.c -- System functions for Windows
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -162,7 +162,7 @@ int32_t mz_os_rename(const char *source_path, const char *target_path)
|
||||
mz_os_unicode_string_delete(&target_path_wide);
|
||||
if (source_path_wide)
|
||||
mz_os_unicode_string_delete(&source_path_wide);
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
if (path_wide == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
handle = CreateFileW(path_wide, FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
handle = CreateFileW(path_wide, FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
@ -632,7 +632,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
if (DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, sizeof(buffer), &length, NULL) == TRUE)
|
||||
{
|
||||
reparse_data = (REPARSE_DATA_BUFFER *)buffer;
|
||||
if ((IsReparseTagMicrosoft(reparse_data->ReparseTag)) &&
|
||||
if ((IsReparseTagMicrosoft(reparse_data->ReparseTag)) &&
|
||||
(reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK))
|
||||
{
|
||||
target_path_len = max_target_path * sizeof(wchar_t);
|
||||
|
10
mz_strm.c
10
mz_strm.c
@ -1,5 +1,5 @@
|
||||
/* mz_strm.c -- Stream interface
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -181,7 +181,7 @@ int32_t mz_stream_copy_to_end(void *target, void *source)
|
||||
return mz_stream_copy_stream_to_end(target, NULL, source, NULL);
|
||||
}
|
||||
|
||||
int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source,
|
||||
int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source,
|
||||
mz_stream_read_cb read_cb, int32_t len)
|
||||
{
|
||||
uint8_t buf[16384];
|
||||
@ -211,7 +211,7 @@ int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *s
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source,
|
||||
int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source,
|
||||
mz_stream_read_cb read_cb)
|
||||
{
|
||||
uint8_t buf[16384];
|
||||
@ -348,7 +348,7 @@ int32_t mz_stream_find_reverse(void *stream, const void *find, int32_t find_size
|
||||
{
|
||||
if (read_size > (int32_t)(max_seek - read_pos))
|
||||
read_size = (int32_t)(max_seek - read_pos);
|
||||
|
||||
|
||||
if (mz_stream_seek(stream, start_pos - (read_pos + read_size), MZ_SEEK_SET) != MZ_OK)
|
||||
break;
|
||||
read = mz_stream_read(stream, buf, read_size);
|
||||
@ -361,7 +361,7 @@ int32_t mz_stream_find_reverse(void *stream, const void *find, int32_t find_size
|
||||
{
|
||||
if (memcmp(&buf[MZ_STREAM_FIND_SIZE - i], find, find_size) != 0)
|
||||
continue;
|
||||
|
||||
|
||||
disk_pos = mz_stream_tell(stream);
|
||||
|
||||
/* Seek to position on disk where the data was found */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm.h -- Stream interface
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -46,7 +46,7 @@ typedef void (*mz_stream_destroy_cb) (void **stream);
|
||||
typedef int32_t (*mz_stream_get_prop_int64_cb) (void *stream, int32_t prop, int64_t *value);
|
||||
typedef int32_t (*mz_stream_set_prop_int64_cb) (void *stream, int32_t prop, int64_t value);
|
||||
|
||||
typedef int32_t (*mz_stream_find_cb) (void *stream, const void *find, int32_t find_size,
|
||||
typedef int32_t (*mz_stream_find_cb) (void *stream, const void *find, int32_t find_size,
|
||||
int64_t max_seek, int64_t *position);
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_buf.c -- Stream for buffering reads/writes
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
This version of ioapi is designed to buffer IO.
|
||||
@ -236,7 +236,7 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size)
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(buffered->writebuf + buffered->writebuf_pos,
|
||||
memcpy(buffered->writebuf + buffered->writebuf_pos,
|
||||
(const char *)buf + (bytes_to_write - bytes_left_to_write), bytes_to_copy);
|
||||
|
||||
mz_stream_buffered_print("Buffered - Write copy (remaining %"PRId32" write %"PRId32":%"PRId32" len %"PRId32")\n",
|
||||
@ -276,7 +276,7 @@ int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin)
|
||||
int32_t bytes_flushed = 0;
|
||||
int32_t err = MZ_OK;
|
||||
|
||||
mz_stream_buffered_print("Buffered - Seek (origin %"PRId32" offset %"PRId64" pos %"PRId64")\n",
|
||||
mz_stream_buffered_print("Buffered - Seek (origin %"PRId32" offset %"PRId64" pos %"PRId64")\n",
|
||||
origin, offset, buffered->position);
|
||||
|
||||
switch (origin)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_buf.h -- Stream for buffering reads/writes
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
This version of ioapi is designed to buffer IO.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_bzip.c -- Stream for bzip inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_bzip.h -- Stream for bzip inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_libcomp.c -- Stream for apple compression
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -57,7 +57,7 @@ int32_t mz_stream_libcomp_open(void *stream, const char *path, int32_t mode)
|
||||
mz_stream_libcomp *libcomp = (mz_stream_libcomp *)stream;
|
||||
int32_t err = 0;
|
||||
int16_t operation = 0;
|
||||
|
||||
|
||||
MZ_UNUSED(path);
|
||||
|
||||
if (libcomp->algorithm == 0)
|
||||
@ -82,16 +82,16 @@ int32_t mz_stream_libcomp_open(void *stream, const char *path, int32_t mode)
|
||||
operation = COMPRESSION_STREAM_DECODE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
err = compression_stream_init(&libcomp->cstream, (compression_stream_operation)operation,
|
||||
(compression_algorithm)libcomp->algorithm);
|
||||
|
||||
|
||||
if (err == COMPRESSION_STATUS_ERROR)
|
||||
{
|
||||
libcomp->error = err;
|
||||
return MZ_OPEN_ERROR;
|
||||
}
|
||||
|
||||
|
||||
libcomp->initialized = 1;
|
||||
libcomp->mode = mode;
|
||||
return MZ_OK;
|
||||
@ -146,7 +146,7 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size)
|
||||
return read;
|
||||
if (read == 0)
|
||||
flags = COMPRESSION_STREAM_FINALIZE;
|
||||
|
||||
|
||||
libcomp->cstream.src_ptr = libcomp->buffer;
|
||||
libcomp->cstream.src_size = (size_t)read;
|
||||
}
|
||||
@ -301,9 +301,9 @@ int32_t mz_stream_libcomp_close(void *stream)
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
compression_stream_destroy(&libcomp->cstream);
|
||||
|
||||
|
||||
libcomp->initialized = 0;
|
||||
|
||||
if (libcomp->error != MZ_OK)
|
||||
@ -360,7 +360,7 @@ int32_t mz_stream_libcomp_set_prop_int64(void *stream, int32_t prop, int64_t val
|
||||
void *mz_stream_libcomp_create(void **stream)
|
||||
{
|
||||
mz_stream_libcomp *libcomp = NULL;
|
||||
|
||||
|
||||
libcomp = (mz_stream_libcomp *)MZ_ALLOC(sizeof(mz_stream_libcomp));
|
||||
if (libcomp != NULL)
|
||||
{
|
||||
@ -369,7 +369,7 @@ void *mz_stream_libcomp_create(void **stream)
|
||||
}
|
||||
if (stream != NULL)
|
||||
*stream = libcomp;
|
||||
|
||||
|
||||
return libcomp;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_libcomp.h -- Stream for apple compression
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_lzma.c -- Stream for lzma inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_lzma.h -- Stream for lzma inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_mem.c -- Stream for memory access
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
This interface is designed to access memory rather than files.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_mem.h -- Stream for memory access
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_sstrm_os.h -- Stream for filesystem access
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_posix.c -- Stream for filesystem access for posix/linux
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_win32.c -- Stream for filesystem access for windows
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -117,10 +117,10 @@ int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
#ifdef MZ_WINRT_API
|
||||
win32->handle = CreateFile2W(path_wide, desired_access, share_mode,
|
||||
win32->handle = CreateFile2W(path_wide, desired_access, share_mode,
|
||||
creation_disposition, NULL);
|
||||
#else
|
||||
win32->handle = CreateFileW(path_wide, desired_access, share_mode, NULL,
|
||||
win32->handle = CreateFileW(path_wide, desired_access, share_mode, NULL,
|
||||
creation_disposition, flags_attribs, NULL);
|
||||
#endif
|
||||
|
||||
@ -186,7 +186,7 @@ int32_t mz_stream_os_write(void *stream, const void *buf, int32_t size)
|
||||
return written;
|
||||
}
|
||||
|
||||
static int32_t mz_stream_os_seekinternal(HANDLE handle, LARGE_INTEGER large_pos,
|
||||
static int32_t mz_stream_os_seekinternal(HANDLE handle, LARGE_INTEGER large_pos,
|
||||
LARGE_INTEGER *new_pos, uint32_t move_method)
|
||||
{
|
||||
#ifdef MZ_WINRT_API
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_pkcrypt.c -- Code for traditional PKWARE encryption
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_pkcrypt.h -- Code for traditional PKWARE encryption
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_split.c -- Stream for split files
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -98,7 +98,7 @@ static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
|
||||
{
|
||||
if (split->path_disk[i] != '.')
|
||||
continue;
|
||||
snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i,
|
||||
snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i,
|
||||
".z%02"PRId32, number_disk + 1);
|
||||
break;
|
||||
}
|
||||
@ -326,7 +326,7 @@ int32_t mz_stream_split_write(void *stream, const void *buf, int32_t size)
|
||||
written = mz_stream_write(split->stream.base, buf_ptr, bytes_to_write);
|
||||
if (written != bytes_to_write)
|
||||
return MZ_WRITE_ERROR;
|
||||
|
||||
|
||||
mz_stream_split_print("Split - Write disk - %"PRId32"\n", written);
|
||||
|
||||
bytes_left -= written;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_split.h -- Stream for split files
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_wzaes.c -- Stream for WinZip AES encryption
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_wzaes.h -- Stream for WinZIP AES encryption
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_zlib.c -- Stream for zlib inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -27,7 +27,7 @@
|
||||
#else
|
||||
# define ZLIB_PREFIX(x) x
|
||||
typedef z_stream zlib_stream;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(DEF_MEM_LEVEL)
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
@ -97,7 +97,7 @@ int32_t mz_stream_zlib_open(void *stream, const char *path, int32_t mode)
|
||||
zlib->zstream.next_out = zlib->buffer;
|
||||
zlib->zstream.avail_out = sizeof(zlib->buffer);
|
||||
|
||||
zlib->error = ZLIB_PREFIX(deflateInit2)(&zlib->zstream, (int8_t)zlib->level, Z_DEFLATED,
|
||||
zlib->error = ZLIB_PREFIX(deflateInit2)(&zlib->zstream, (int8_t)zlib->level, Z_DEFLATED,
|
||||
zlib->window_bits, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
|
||||
#endif
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_strm_zlib.h -- Stream for zlib inflate/deflate
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
|
76
mz_zip.c
76
mz_zip.c
@ -1,5 +1,5 @@
|
||||
/* zip.c -- Zip manipulation
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -290,11 +290,11 @@ static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file
|
||||
if ((err == MZ_OK) && (file_info->comment_size > 0))
|
||||
err = mz_stream_copy(file_extra_stream, stream, file_info->comment_size);
|
||||
mz_stream_write_uint8(file_extra_stream, 0);
|
||||
|
||||
|
||||
linkname_pos = mz_stream_tell(file_extra_stream);
|
||||
/* Overwrite if we encounter UNIX1 extra block */
|
||||
mz_stream_write_uint8(file_extra_stream, 0);
|
||||
|
||||
|
||||
if ((err == MZ_OK) && (file_info->extrafield_size > 0))
|
||||
{
|
||||
/* Seek to and parse the extra field */
|
||||
@ -457,7 +457,7 @@ static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file
|
||||
field_pos += field_length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get pointers to variable length data */
|
||||
mz_stream_mem_get_buffer(file_extra_stream, (const void **)&file_info->filename);
|
||||
mz_stream_mem_get_buffer_at(file_extra_stream, extrafield_pos, (const void **)&file_info->extrafield);
|
||||
@ -610,7 +610,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
if (file_info->extrafield_size > 0)
|
||||
{
|
||||
mz_stream_mem_create(&file_extra_stream);
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield,
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield,
|
||||
file_info->extrafield_size);
|
||||
|
||||
do
|
||||
@ -635,7 +635,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
}
|
||||
while (err_mem == MZ_OK);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_WZAES
|
||||
if (!skip_aes)
|
||||
{
|
||||
@ -657,7 +657,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
field_length_ntfs = 8 + 8 + 8 + 4 + 2 + 2;
|
||||
extrafield_size += 4 + field_length_ntfs;
|
||||
}
|
||||
|
||||
|
||||
/* Unix1 symbolic links */
|
||||
if (file_info->linkname != NULL && *file_info->linkname != 0)
|
||||
{
|
||||
@ -665,7 +665,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
field_length_unix1 = 12 + linkname_size;
|
||||
extrafield_size += 4 + field_length_unix1;
|
||||
}
|
||||
|
||||
|
||||
if (local)
|
||||
err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_LOCALHEADER);
|
||||
else
|
||||
@ -739,7 +739,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
|
||||
if (mask)
|
||||
{
|
||||
snprintf(masked_name, sizeof(masked_name), "%"PRIx32"_%"PRIx64,
|
||||
snprintf(masked_name, sizeof(masked_name), "%"PRIx32"_%"PRIx64,
|
||||
file_info->disk_number, file_info->disk_offset);
|
||||
filename = masked_name;
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ static int32_t mz_zip_read_cd(void *handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (err == MZ_OK)
|
||||
{
|
||||
if (eocd_pos < zip->cd_offset)
|
||||
@ -1284,7 +1284,7 @@ static int32_t mz_zip_recover_cd(void *handle)
|
||||
|
||||
if (mz_stream_is_open(cd_mem_stream) != MZ_OK)
|
||||
err = mz_stream_mem_open(cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE);
|
||||
|
||||
|
||||
mz_stream_mem_create(&local_file_info_stream);
|
||||
mz_stream_mem_open(local_file_info_stream, NULL, MZ_OPEN_MODE_CREATE);
|
||||
|
||||
@ -1324,7 +1324,7 @@ static int32_t mz_zip_recover_cd(void *handle)
|
||||
local_file_info.extrafield_size, MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK)
|
||||
zip64 = 1;
|
||||
|
||||
err = mz_zip_entry_read_descriptor(zip->stream, zip64, &crc32,
|
||||
err = mz_zip_entry_read_descriptor(zip->stream, zip64, &crc32,
|
||||
&compressed_size, &uncompressed_size);
|
||||
|
||||
if (local_file_info.crc == 0)
|
||||
@ -1334,7 +1334,7 @@ static int32_t mz_zip_recover_cd(void *handle)
|
||||
if (local_file_info.uncompressed_size == 0)
|
||||
local_file_info.uncompressed_size = uncompressed_size;
|
||||
}
|
||||
|
||||
|
||||
/* Rewrite central dir with local headers and offsets */
|
||||
if (err == MZ_OK)
|
||||
err = mz_zip_entry_write_header(cd_mem_stream, 0, &local_file_info);
|
||||
@ -1345,7 +1345,7 @@ static int32_t mz_zip_recover_cd(void *handle)
|
||||
|
||||
mz_stream_mem_delete(&local_file_info_stream);
|
||||
|
||||
mz_zip_print("Zip - Recover cd complete (cddisk %"PRId32" entries %"PRId64")\n",
|
||||
mz_zip_print("Zip - Recover cd complete (cddisk %"PRId32" entries %"PRId64")\n",
|
||||
disk_number_with_cd, number_entry);
|
||||
|
||||
if (number_entry == 0)
|
||||
@ -1403,7 +1403,7 @@ int32_t mz_zip_open(void *handle, void *stream, int32_t mode)
|
||||
zip->stream = stream;
|
||||
|
||||
mz_stream_mem_create(&zip->cd_mem_stream);
|
||||
|
||||
|
||||
if (mode & MZ_OPEN_MODE_WRITE)
|
||||
{
|
||||
mz_stream_mem_open(zip->cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE);
|
||||
@ -1481,7 +1481,7 @@ int32_t mz_zip_close(void *handle)
|
||||
|
||||
if (zip == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_zip_print("Zip - Close\n");
|
||||
|
||||
if (mz_zip_entry_is_open(handle) == MZ_OK)
|
||||
@ -1812,8 +1812,8 @@ static int32_t mz_zip_seek_to_local_header(void *handle)
|
||||
mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, -1);
|
||||
else
|
||||
mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, zip->file_info.disk_number);
|
||||
|
||||
mz_zip_print("Zip - Entry - Seek local (disk %"PRId32" offset %"PRId64")\n",
|
||||
|
||||
mz_zip_print("Zip - Entry - Seek local (disk %"PRId32" offset %"PRId64")\n",
|
||||
zip->file_info.disk_number, zip->file_info.disk_offset);
|
||||
|
||||
/* Guard against seek overflows */
|
||||
@ -1896,8 +1896,8 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int1
|
||||
}
|
||||
|
||||
memcpy(&zip->file_info, file_info, sizeof(mz_zip_file));
|
||||
|
||||
mz_zip_print("Zip - Entry - Write open - %s (level %"PRId16" raw %"PRId8")\n",
|
||||
|
||||
mz_zip_print("Zip - Entry - Write open - %s (level %"PRId16" raw %"PRId8")\n",
|
||||
zip->file_info.filename, compress_level, raw);
|
||||
|
||||
mz_stream_seek(zip->file_info_stream, 0, MZ_SEEK_SET);
|
||||
@ -1918,7 +1918,7 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int1
|
||||
if (file_info->comment != NULL)
|
||||
mz_stream_write(zip->file_info_stream, file_info->comment, file_info->comment_size);
|
||||
mz_stream_write_uint8(zip->file_info_stream, 0);
|
||||
|
||||
|
||||
linkname_pos = mz_stream_tell(zip->file_info_stream);
|
||||
if (file_info->linkname != NULL)
|
||||
mz_stream_write(zip->file_info_stream, file_info->linkname, (int32_t)strlen(file_info->linkname));
|
||||
@ -1928,7 +1928,7 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int1
|
||||
mz_stream_mem_get_buffer_at(zip->file_info_stream, extrafield_pos, (const void **)&zip->file_info.extrafield);
|
||||
mz_stream_mem_get_buffer_at(zip->file_info_stream, comment_pos, (const void **)&zip->file_info.comment);
|
||||
mz_stream_mem_get_buffer_at(zip->file_info_stream, linkname_pos, (const void **)&zip->file_info.linkname);
|
||||
|
||||
|
||||
if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE)
|
||||
{
|
||||
if ((compress_level == 8) || (compress_level == 9))
|
||||
@ -2022,7 +2022,7 @@ int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len)
|
||||
return written;
|
||||
}
|
||||
|
||||
int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size,
|
||||
int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size,
|
||||
int64_t *uncompressed_size)
|
||||
{
|
||||
mz_zip *zip = (mz_zip *)handle;
|
||||
@ -2043,11 +2043,11 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress
|
||||
*compressed_size = zip->file_info.compressed_size;
|
||||
if (uncompressed_size != NULL)
|
||||
*uncompressed_size = zip->file_info.uncompressed_size;
|
||||
|
||||
|
||||
mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &total_in);
|
||||
|
||||
if ((zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) &&
|
||||
((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0) &&
|
||||
((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0) &&
|
||||
(crc32 != NULL || compressed_size != NULL || uncompressed_size != NULL))
|
||||
{
|
||||
/* Check to see if data descriptor is zip64 bit format or not */
|
||||
@ -2059,14 +2059,14 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress
|
||||
|
||||
/* Seek to end of compressed stream since we might have over-read during compression */
|
||||
if (err == MZ_OK)
|
||||
err = mz_stream_seek(zip->stream, MZ_ZIP_SIZE_LD_ITEM +
|
||||
(int64_t)zip->local_file_info.filename_size +
|
||||
(int64_t)zip->local_file_info.extrafield_size +
|
||||
err = mz_stream_seek(zip->stream, MZ_ZIP_SIZE_LD_ITEM +
|
||||
(int64_t)zip->local_file_info.filename_size +
|
||||
(int64_t)zip->local_file_info.extrafield_size +
|
||||
total_in, MZ_SEEK_CUR);
|
||||
|
||||
/* Read data descriptor */
|
||||
if (err == MZ_OK)
|
||||
err = mz_zip_entry_read_descriptor(zip->stream, zip64,
|
||||
err = mz_zip_entry_read_descriptor(zip->stream, zip64,
|
||||
crc32, compressed_size, uncompressed_size);
|
||||
}
|
||||
|
||||
@ -2093,7 +2093,7 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size,
|
||||
int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size,
|
||||
int64_t uncompressed_size)
|
||||
{
|
||||
mz_zip *zip = (mz_zip *)handle;
|
||||
@ -2102,7 +2102,7 @@ int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compresse
|
||||
|
||||
if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
mz_stream_close(zip->compress_stream);
|
||||
|
||||
if (!zip->entry_raw)
|
||||
@ -2146,16 +2146,16 @@ int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compresse
|
||||
}
|
||||
|
||||
if (zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO)
|
||||
err = mz_zip_entry_write_descriptor(zip->stream,
|
||||
err = mz_zip_entry_write_descriptor(zip->stream,
|
||||
zip64, 0, compressed_size, 0);
|
||||
else
|
||||
err = mz_zip_entry_write_descriptor(zip->stream,
|
||||
err = mz_zip_entry_write_descriptor(zip->stream,
|
||||
zip64, crc32, compressed_size, uncompressed_size);
|
||||
}
|
||||
|
||||
/* Write file info to central directory */
|
||||
|
||||
mz_zip_print("Zip - Entry - Write cd (ucs %"PRId64" cs %"PRId64" crc 0x%08"PRIx32")\n",
|
||||
mz_zip_print("Zip - Entry - Write cd (ucs %"PRId64" cs %"PRId64" crc 0x%08"PRIx32")\n",
|
||||
uncompressed_size, compressed_size, crc32);
|
||||
|
||||
zip->file_info.crc = crc32;
|
||||
@ -2206,7 +2206,7 @@ int32_t mz_zip_entry_is_symlink(void *handle)
|
||||
return MZ_EXIST_ERROR;
|
||||
if (zip->file_info.linkname == NULL || *zip->file_info.linkname == 0)
|
||||
return MZ_EXIST_ERROR;
|
||||
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
@ -2502,7 +2502,7 @@ int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t targ
|
||||
/* If high bytes are set, it contains unix specific attributes */
|
||||
if ((src_attrib >> 16) != 0)
|
||||
src_attrib >>= 16;
|
||||
|
||||
|
||||
*target_attrib = src_attrib;
|
||||
return MZ_OK;
|
||||
}
|
||||
@ -2517,9 +2517,9 @@ int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attr
|
||||
{
|
||||
if (win32_attrib == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
||||
*win32_attrib = 0;
|
||||
|
||||
|
||||
/* S_IWUSR | S_IWGRP | S_IWOTH | S_IXUSR | S_IXGRP | S_IXOTH */
|
||||
if ((posix_attrib & 0000333) == 0 && (posix_attrib & 0000444) != 0)
|
||||
*win32_attrib |= 0x01; /* FILE_ATTRIBUTE_READONLY */
|
||||
|
8
mz_zip.h
8
mz_zip.h
@ -1,5 +1,5 @@
|
||||
/* mz_zip.h -- Zip manipulation
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -107,7 +107,7 @@ int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password);
|
||||
int32_t mz_zip_entry_read(void *handle, void *buf, int32_t len);
|
||||
/* Read bytes from the current file in the zip file */
|
||||
|
||||
int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size,
|
||||
int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size,
|
||||
int64_t *uncompressed_size);
|
||||
/* Close the current file for reading and get data descriptor values */
|
||||
|
||||
@ -118,7 +118,7 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info,
|
||||
int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len);
|
||||
/* Write bytes from the current file in the zip file */
|
||||
|
||||
int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size,
|
||||
int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size,
|
||||
int64_t uncompressed_size);
|
||||
/* Close the current file for writing and set data descriptor values */
|
||||
|
||||
@ -186,7 +186,7 @@ int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby);
|
||||
int32_t mz_zip_attrib_is_symlink(uint32_t attrib, int32_t version_madeby);
|
||||
/* Checks to see if the attribute is a symbolic link based on platform */
|
||||
|
||||
int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys,
|
||||
int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys,
|
||||
uint32_t *target_attrib);
|
||||
/* Converts file attributes from one host system to another */
|
||||
|
||||
|
50
mz_zip_rw.c
50
mz_zip_rw.c
@ -1,5 +1,5 @@
|
||||
/* mz_zip_rw.c -- Zip reader/writer
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -255,7 +255,7 @@ int32_t mz_zip_reader_unzip_cd(void *handle)
|
||||
|
||||
if (strcmp(cd_info->filename, MZ_ZIP_CD_FILENAME) != 0)
|
||||
return mz_zip_reader_goto_first_entry(handle);
|
||||
|
||||
|
||||
err = mz_zip_reader_entry_open(handle);
|
||||
if (err != MZ_OK)
|
||||
return err;
|
||||
@ -278,7 +278,7 @@ int32_t mz_zip_reader_unzip_cd(void *handle)
|
||||
|
||||
err = mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET);
|
||||
if (err == MZ_OK)
|
||||
err = mz_stream_copy_stream(cd_mem_stream, NULL, handle, mz_zip_reader_entry_read,
|
||||
err = mz_stream_copy_stream(cd_mem_stream, NULL, handle, mz_zip_reader_entry_read,
|
||||
(int32_t)cd_info->uncompressed_size);
|
||||
|
||||
if (err == MZ_OK)
|
||||
@ -512,7 +512,7 @@ int32_t mz_zip_reader_entry_sign_verify(void *handle)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_stream_mem_create(&file_extra_stream);
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
reader->file_info->extrafield_size);
|
||||
|
||||
err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_SIGN, &signature_size);
|
||||
@ -554,7 +554,7 @@ int32_t mz_zip_reader_entry_get_hash(void *handle, uint16_t algorithm, uint8_t *
|
||||
uint16_t cur_digest_size = 0;
|
||||
|
||||
mz_stream_mem_create(&file_extra_stream);
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
reader->file_info->extrafield_size);
|
||||
|
||||
do
|
||||
@ -598,7 +598,7 @@ int32_t mz_zip_reader_entry_get_first_hash(void *handle, uint16_t *algorithm, ui
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
mz_stream_mem_create(&file_extra_stream);
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield,
|
||||
reader->file_info->extrafield_size);
|
||||
|
||||
err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_HASH, NULL);
|
||||
@ -606,7 +606,7 @@ int32_t mz_zip_reader_entry_get_first_hash(void *handle, uint16_t *algorithm, ui
|
||||
err = mz_stream_read_uint16(file_extra_stream, &cur_algorithm);
|
||||
if (err == MZ_OK)
|
||||
err = mz_stream_read_uint16(file_extra_stream, &cur_digest_size);
|
||||
|
||||
|
||||
if (algorithm != NULL)
|
||||
*algorithm = cur_algorithm;
|
||||
if (digest_size != NULL)
|
||||
@ -777,14 +777,14 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path)
|
||||
/* We want to overwrite the file so we delete the existing one */
|
||||
mz_os_unlink(pathwfs);
|
||||
}
|
||||
|
||||
|
||||
/* If symbolic link then properly construct destination path and link path */
|
||||
if (mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK)
|
||||
{
|
||||
mz_path_remove_slash(pathwfs);
|
||||
mz_path_remove_filename(directory);
|
||||
}
|
||||
|
||||
|
||||
/* Create the output directory if it doesn't already exist */
|
||||
if (mz_os_is_dir(directory) != MZ_OK)
|
||||
{
|
||||
@ -1285,7 +1285,7 @@ int32_t mz_zip_writer_close(void *handle)
|
||||
mz_stream_mem_close(writer->mem_stream);
|
||||
mz_stream_mem_delete(&writer->mem_stream);
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1335,7 +1335,7 @@ int32_t mz_zip_writer_zip_cd(void *handle)
|
||||
err = mz_zip_writer_entry_open(handle, &cd_file);
|
||||
if (err == MZ_OK)
|
||||
{
|
||||
mz_stream_copy_stream(handle, mz_zip_writer_entry_write, cd_mem_stream,
|
||||
mz_stream_copy_stream(handle, mz_zip_writer_entry_write, cd_mem_stream,
|
||||
NULL, (int32_t)cd_mem_length);
|
||||
|
||||
mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET);
|
||||
@ -1370,7 +1370,7 @@ int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info)
|
||||
if ((writer->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (password == NULL) &&
|
||||
(writer->password_cb != NULL))
|
||||
{
|
||||
writer->password_cb(handle, writer->password_userdata, &writer->file_info,
|
||||
writer->password_cb(handle, writer->password_userdata, &writer->file_info,
|
||||
password_buf, sizeof(password_buf));
|
||||
password = password_buf;
|
||||
}
|
||||
@ -1386,7 +1386,7 @@ int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info)
|
||||
#endif
|
||||
|
||||
/* Open entry in zip */
|
||||
err = mz_zip_entry_write_open(writer->zip_handle, &writer->file_info, writer->compress_level,
|
||||
err = mz_zip_entry_write_open(writer->zip_handle, &writer->file_info, writer->compress_level,
|
||||
writer->raw, password);
|
||||
|
||||
return err;
|
||||
@ -1457,7 +1457,7 @@ int32_t mz_zip_writer_entry_close(void *handle)
|
||||
else
|
||||
err = mz_zip_entry_close(writer->zip_handle);
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1474,7 +1474,7 @@ int32_t mz_zip_writer_entry_write(void *handle, const void *buf, int32_t len)
|
||||
}
|
||||
|
||||
#if !defined(MZ_ZIP_NO_ENCRYPTION) && !defined(MZ_ZIP_NO_SIGNING)
|
||||
int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message_size,
|
||||
int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message_size,
|
||||
uint8_t *cert_data, int32_t cert_data_size, const char *cert_pwd)
|
||||
{
|
||||
mz_zip_writer *writer = (mz_zip_writer *)handle;
|
||||
@ -1489,7 +1489,7 @@ int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
/* Sign message with certificate */
|
||||
err = mz_crypt_sign(message, message_size, cert_data, cert_data_size, cert_pwd,
|
||||
err = mz_crypt_sign(message, message_size, cert_data, cert_data_size, cert_pwd,
|
||||
&signature, &signature_size);
|
||||
|
||||
if ((err == MZ_OK) && (signature != NULL))
|
||||
@ -1690,9 +1690,9 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen
|
||||
mz_os_get_file_date(path, &file_info.modified_date, &file_info.accessed_date,
|
||||
&file_info.creation_date);
|
||||
mz_os_get_file_attribs(path, &src_attrib);
|
||||
|
||||
|
||||
src_sys = MZ_HOST_SYSTEM(file_info.version_madeby);
|
||||
|
||||
|
||||
if ((src_sys != MZ_HOST_SYSTEM_MSDOS) && (src_sys != MZ_HOST_SYSTEM_WINDOWS_NTFS))
|
||||
{
|
||||
/* High bytes are OS specific attributes, low byte is always DOS attributes */
|
||||
@ -1717,7 +1717,7 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen
|
||||
mz_stream_os_create(&stream);
|
||||
err = mz_stream_os_open(stream, path, MZ_OPEN_MODE_READ);
|
||||
}
|
||||
|
||||
|
||||
if (err == MZ_OK)
|
||||
err = mz_zip_writer_add_info(handle, stream, mz_stream_read, &file_info);
|
||||
|
||||
@ -1730,7 +1730,7 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path,
|
||||
int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path,
|
||||
uint8_t include_path, uint8_t recursive)
|
||||
{
|
||||
mz_zip_writer *writer = (mz_zip_writer *)handle;
|
||||
@ -1775,19 +1775,19 @@ int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_
|
||||
filenameinzip += strlen(root_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!writer->store_links && !writer->follow_links)
|
||||
{
|
||||
if (mz_os_is_symlink(path) == MZ_OK)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
if (*filenameinzip != 0)
|
||||
err = mz_zip_writer_add_file(handle, path, filenameinzip);
|
||||
|
||||
if (!is_dir)
|
||||
return err;
|
||||
|
||||
|
||||
if (writer->store_links)
|
||||
{
|
||||
if (mz_os_is_symlink(path) == MZ_OK)
|
||||
@ -1861,7 +1861,7 @@ int32_t mz_zip_writer_copy_from_reader(void *handle, void *reader)
|
||||
|
||||
err = mz_zip_writer_entry_open(writer, file_info);
|
||||
|
||||
if ((err == MZ_OK) &&
|
||||
if ((err == MZ_OK) &&
|
||||
(mz_zip_attrib_is_dir(writer->file_info.external_fa, writer->file_info.version_madeby) != MZ_OK))
|
||||
{
|
||||
err = mz_zip_writer_add(writer, reader_zip_handle, mz_zip_entry_read);
|
||||
@ -2064,7 +2064,7 @@ void *mz_zip_writer_create(void **handle)
|
||||
writer->compress_method = MZ_COMPRESS_METHOD_BZIP2;
|
||||
#elif defined(HAVE_LZMA)
|
||||
writer->compress_method = MZ_COMPRESS_METHOD_LZMA;
|
||||
#else
|
||||
#else
|
||||
writer->compress_method = MZ_COMPRESS_METHOD_STORE;
|
||||
#endif
|
||||
writer->compress_level = MZ_COMPRESS_LEVEL_BEST;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* mz_zip_rw.h -- Zip reader/writer
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2010-2019 Nathan Moinvaziri
|
||||
@ -196,7 +196,7 @@ int32_t mz_zip_writer_entry_close(void *handle);
|
||||
int32_t mz_zip_writer_entry_write(void *handle, const void *buf, int32_t len);
|
||||
/* Writes data into entry for zip */
|
||||
|
||||
int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message_size,
|
||||
int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message_size,
|
||||
uint8_t *cert_data, int32_t cert_data_size, const char *cert_pwd);
|
||||
/* Signs uncompressed content of entry, call before closing */
|
||||
|
||||
@ -217,7 +217,7 @@ int32_t mz_zip_writer_add_buffer(void *handle, void *buf, int32_t len, mz_zip_fi
|
||||
int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filename_in_zip);
|
||||
/* Adds an entry to the zip from a file */
|
||||
|
||||
int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, uint8_t include_path,
|
||||
int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, uint8_t include_path,
|
||||
uint8_t recursive);
|
||||
/* Enumerates a directory or pattern and adds entries to the zip */
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* standalone.c - Standalone fuzzer tester
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2018 sebpop
|
||||
@ -57,7 +57,7 @@ int main(int argc, char **argv)
|
||||
if (err != MZ_OK)
|
||||
{
|
||||
printf("Skipping %s (%"PRId32")\n", argv[i], err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mz_stream_os_seek(stream, 0, MZ_SEEK_END);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* unzip_fuzzer.c - Unzip fuzzer for libFuzzer
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2018 The Chromium Authors
|
||||
@ -75,9 +75,9 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
/* Return value isn't checked here because we can't predict
|
||||
/* Return value isn't checked here because we can't predict
|
||||
what the value will be. */
|
||||
|
||||
|
||||
mz_zip_entry_is_dir(handle);
|
||||
entry_pos = mz_zip_get_entry(handle);
|
||||
if (entry_pos < 0)
|
||||
@ -90,13 +90,13 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
err = mz_zip_entry_close(handle);
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
|
||||
err = mz_zip_goto_next_entry(handle);
|
||||
}
|
||||
|
||||
mz_zip_entry_close(handle);
|
||||
|
||||
/* Return value isn't checked here because we can't predict what the value
|
||||
/* Return value isn't checked here because we can't predict what the value
|
||||
will be. */
|
||||
|
||||
mz_zip_locate_entry(handle, MZ_FUZZ_TEST_FILENAME, 0);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* zip_fuzzer.c - Zip fuzzer for libFuzzer
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2018 The Chromium Authors
|
||||
|
30
test/test.c
30
test/test.c
@ -1,5 +1,5 @@
|
||||
/* test.c - Test bed area
|
||||
Version 2.8.8, May 22, 2019
|
||||
Version 2.8.9, July 4, 2019
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2018-2019 Nathan Moinvaziri
|
||||
@ -111,7 +111,7 @@ void test_encrypt(char *method, mz_stream_create_cb crypt_create, char *password
|
||||
|
||||
printf("%s encrypted %"PRId32"\n", encrypt_path, written);
|
||||
}
|
||||
|
||||
|
||||
mz_stream_os_delete(&out_stream);
|
||||
mz_stream_os_create(&in_stream);
|
||||
|
||||
@ -127,7 +127,7 @@ void test_encrypt(char *method, mz_stream_create_cb crypt_create, char *password
|
||||
read = mz_stream_read(crypt_out_stream, buf, read);
|
||||
mz_stream_close(crypt_out_stream);
|
||||
}
|
||||
|
||||
|
||||
mz_stream_delete(&crypt_out_stream);
|
||||
|
||||
mz_stream_os_close(in_stream);
|
||||
@ -138,7 +138,7 @@ void test_encrypt(char *method, mz_stream_create_cb crypt_create, char *password
|
||||
|
||||
mz_stream_os_delete(&in_stream);
|
||||
mz_stream_os_create(&out_stream);
|
||||
|
||||
|
||||
if (mz_stream_os_open(out_stream, decrypt_path, MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_WRITE) == MZ_OK)
|
||||
{
|
||||
mz_stream_os_write(out_stream, buf, read);
|
||||
@ -205,7 +205,7 @@ void test_compress(char *method, mz_stream_create_cb create_compress)
|
||||
|
||||
mz_stream_os_close(out_stream);
|
||||
}
|
||||
|
||||
|
||||
mz_stream_os_delete(&out_stream);
|
||||
mz_stream_os_create(&in_stream);
|
||||
|
||||
@ -242,7 +242,7 @@ void test_compress(char *method, mz_stream_create_cb create_compress)
|
||||
|
||||
printf("%s crc 0x%08x\n", filename, crc32);
|
||||
}
|
||||
|
||||
|
||||
mz_stream_os_delete(&out_stream);
|
||||
}
|
||||
|
||||
@ -269,12 +269,12 @@ void test_stream_wzaes(void)
|
||||
uint8_t key[MZ_HASH_SHA1_SIZE];
|
||||
const char *password = "passwordpasswordpasswordpassword";
|
||||
const char *salt = "8F3472E4EA57F56E36F30246DC22C173";
|
||||
|
||||
|
||||
|
||||
printf("Pbkdf2 password - %s\n", password);
|
||||
printf("Pbkdf2 salt - %s\n", salt);
|
||||
|
||||
err = mz_crypt_pbkdf2((uint8_t *)password, (int32_t)strlen(password),
|
||||
err = mz_crypt_pbkdf2((uint8_t *)password, (int32_t)strlen(password),
|
||||
(uint8_t *)salt, (int32_t)strlen(salt), iteration_count, key, sizeof(key));
|
||||
|
||||
if (err == MZ_OK)
|
||||
@ -440,7 +440,7 @@ int32_t test_stream_find_run(char *name, int32_t count, const uint8_t *find, int
|
||||
last_pos = mz_stream_tell(mem_stream);
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
|
||||
printf("Find postzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
printf("Find postzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
name, find_size, position, (position == 0));
|
||||
|
||||
if (position != 0 || last_pos != position)
|
||||
@ -453,7 +453,7 @@ int32_t test_stream_find_run(char *name, int32_t count, const uint8_t *find, int
|
||||
mz_stream_write_uint8(mem_stream, 0);
|
||||
for (x = 0; x < find_size; x += 1)
|
||||
mz_stream_write_uint8(mem_stream, find[x]);
|
||||
|
||||
|
||||
if (find_cb == mz_stream_find)
|
||||
mz_stream_seek(mem_stream, 0, MZ_SEEK_SET);
|
||||
|
||||
@ -461,7 +461,7 @@ int32_t test_stream_find_run(char *name, int32_t count, const uint8_t *find, int
|
||||
last_pos = mz_stream_tell(mem_stream);
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
|
||||
printf("Find prezero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
printf("Find prezero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
name, find_size, position, (position == i));
|
||||
|
||||
if (position != i || last_pos != position)
|
||||
@ -484,7 +484,7 @@ int32_t test_stream_find_run(char *name, int32_t count, const uint8_t *find, int
|
||||
last_pos = mz_stream_tell(mem_stream);
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
|
||||
printf("Find equalzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
printf("Find equalzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
name, find_size, position, (position == i));
|
||||
|
||||
if (position != i || last_pos != position)
|
||||
@ -508,7 +508,7 @@ int32_t test_stream_find_run(char *name, int32_t count, const uint8_t *find, int
|
||||
last_pos = mz_stream_tell(mem_stream);
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
|
||||
printf("Find unequalzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
printf("Find unequalzero - %s (len %"PRId32" pos %"PRId64" ok %"PRId32")\n",
|
||||
name, find_size, position, (position == i));
|
||||
|
||||
if (position != i || last_pos != position)
|
||||
@ -565,7 +565,7 @@ void test_crypt_sha(void)
|
||||
for (i = 0, p = 0; i < (int32_t)sizeof(hash); i += 1, p += 2)
|
||||
snprintf(computed_hash + p, sizeof(computed_hash) - p, "%02x", hash[i]);
|
||||
computed_hash[p] = 0;
|
||||
|
||||
|
||||
printf("Sha1 hash computed - %s\n", computed_hash);
|
||||
printf("Sha1 hash expected - 3efb8392b6cd8e14bd76bd08081521dc73df418c\n");
|
||||
|
||||
@ -582,7 +582,7 @@ void test_crypt_sha(void)
|
||||
for (i = 0, p = 0; i < (int32_t)sizeof(hash256); i += 1, p += 2)
|
||||
snprintf(computed_hash + p, sizeof(computed_hash) - p, "%02x", hash256[i]);
|
||||
computed_hash[p] = 0;
|
||||
|
||||
|
||||
printf("Sha256 hash computed - %s\n", computed_hash);
|
||||
printf("Sha256 hash expected - 7a31ea0848525f7ebfeec9ee532bcc5d6d26772427e097b86cf440a56546541c\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user