Minizip zlib contribution fork with latest bug fixes that supports PKWARE disk spanning, AES encryption, and IO buffering
Go to file
David Korth 4d76c8b508 mz_os_win32.c: kernel32.dll is always loaded, so use GetModuleHandleW().
The kernel32.dll pathname code had two issues:

1. Using sizeof() for wchar_t[]. sizeof() returns the number of bytes,
   but the wcs*() functions need number of characters, so we end up
   telling wcsncat() that the buffer is twice as big as it actually is.

2. wcsncat()'s size parameter is supposed to be the *remaining* size
   in the buffer, not the total size. wcscat_s() should be used instead,
   since it takes the total size of the buffer.

None of this is actually needed, since kernel32.dll is used by all
Windows programs, so it's always loaded in memory.
2020-02-08 22:13:10 -05:00
.github Don't set output name for cmd targets due to linker issues conflicting with minizip static library with Visual Studio. 2020-01-03 23:06:06 -08:00
doc Added starting point for documentation. 2020-02-08 09:55:20 -08:00
lib Added notice about third party licenses. 2019-11-04 08:57:41 -08:00
test Version 2.9.1. 2019-11-15 13:24:17 -08:00
.codecov.yml Added support for code coverage. 2019-11-03 17:02:03 -08:00
CMakeLists.txt Don't set output name for cmd targets due to linker issues conflicting with minizip static library with Visual Studio. 2020-01-03 23:06:06 -08:00
LICENSE minor URL correction, remove EOL spaces, add EOF newlines. 2019-09-15 20:11:28 +00:00
minigzip.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
minizip.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
minizip.pc.cmakein Use Requires: zlib to fix pkg-config ordering of static libs 2018-03-13 20:14:45 +11:00
Minizip.podspec -updated a search sources rule 2019-12-14 16:14:03 +04:00
mz_compat.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_compat.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt_apple.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt_brg.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt_openssl.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt_win32.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_crypt.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_os_posix.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_os_win32.c mz_os_win32.c: kernel32.dll is always loaded, so use GetModuleHandleW(). 2020-02-08 22:13:10 -05:00
mz_os.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_os.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_buf.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_buf.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_bzip.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_bzip.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_libcomp.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_libcomp.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_lzma.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_lzma.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_mem.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_mem.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_os_posix.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_os_win32.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_os.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_pkcrypt.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_pkcrypt.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_split.c Always get the size of the current disk which is necessary also for seeking to proper disk when updating the local header values during append operation. 2020-01-04 17:42:51 -08:00
mz_strm_split.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_wzaes.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_wzaes.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_zlib.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm_zlib.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm.c Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_strm.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_zip_rw.c Fixed bug saving file during erase when data descriptor not being used. 2020-01-04 16:53:10 -08:00
mz_zip_rw.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
mz_zip.c Enable data descriptor by default since it doesn't do any seek backs to update the local header. 2020-01-04 16:55:21 -08:00
mz_zip.h Allow the ability to disable use of data descriptor. Using data descriptor prevents having to seek backwards or to another disk while writing. However, the local headers aren't updated with the crc or size values. #440 2020-01-03 22:57:15 -08:00
mz.h Version 2.9.1. 2019-11-15 13:24:17 -08:00
README.md Added starting point for documentation. 2020-02-08 09:55:20 -08:00

minizip 2.9.1

minizip is a zip manipulation library written in C that is supported on Windows, macOS, and Linux.

Master Branch Status Fuzzing Status CodeFactor License: Zlib codecov.io

Developed and maintained by Nathan Moinvaziri.

Branches

Name Description
master Modern rewrite that includes more advanced features, improvements in code maintainability and readability, and the reduction of duplicate code. Compatibility layer provided for older versions.
dev Latest development code
1.2 Drop-in replacement for zlib's minizip that includes WinZip AES encryption, disk splitting, I/O buffering and some additional fixes.
1.1 Original minizip as of zlib 1.2.11.

History

Minizip was originally developed by Gilles Vollant in 1998. It was first included in the zlib distribution as an additional code contribution starting in zlib 1.1.2. Since that time, it has been continually improved upon and contributed to by many people. The original project can still be found in the zlib distribution that is maintained by Mark Adler.

My work with the minizip library started in 2006 when I fixed a few bugs I found and submitted them to Gilles Vollant. In 2010, I implemented WinZip AES encryption, disk splitting, and I/O buffering that were necessary for another project I was working on. Shortly after, I created this public repository so I could share my improvements with the community. In early 2017, I began the work to refactor and rewrite the library as version 2 because it had become difficult to maintain and code readability suffered over the years.

Features

  • Creating and extracting zip archives.
  • Adding and removing entries from zip archives.
  • Read and write raw zip entry data.
  • Reading and writing zip archives from memory.
  • Zlib, BZIP2, and LZMA compression methods.
  • Password protection through Traditional PKWARE and WinZIP AES encryption.
  • Buffered streaming for improved I/O performance.
  • NTFS timestamp support for UTC last modified, last accessed, and creation dates.
  • Disk split support for splitting zip archives into multiple files.
  • Preservation of file attributes across file systems.
  • Follow and store symbolic links.
  • Unicode filename support through UTF-8 encoding.
  • Legacy character encoding support CP437, CP932, CP936, CP950.
  • Turn off compilation of compression, decompression, or encryption.
  • Windows (Win32 & WinRT), macOS and Linux platform support.
  • Streaming interface for easy implementation of additional platforms.
  • Support for Apple's compression library ZLIB implementation.
  • Zero out local file header information.
  • Zip/unzip of central directory to reduce size.
  • Ability to generate and verify CMS signature for each entry.
  • Recover the central directory if it is corrupt or missing.
  • Example minizip command line tool.

Build

To generate project files for your platform:

  1. Download and install cmake (version 3.11 or later recommended).
  2. Run cmake in the minizip directory.
cmake . -DMZ_BUILD_TEST=ON
cmake --build .

Build Options

Name Description Default Value
MZ_COMPAT Enables compatibility layer ON
MZ_ZLIB Enables ZLIB compression ON
MZ_BZIP2 Enables BZIP2 compression ON
MZ_LZMA Enables LZMA compression ON
MZ_PKCRYPT Enables PKWARE traditional encryption ON
MZ_WZAES Enables WinZIP AES encryption ON
MZ_LIBCOMP Enables Apple compression OFF
MZ_OPENSSL Enables OpenSSL encryption OFF
MZ_BRG Enables Brian Gladman's library OFF
MZ_SIGNING Enables zip signing support ON
MZ_COMPRESS_ONLY Only support compression OFF
MZ_DECOMPRESS_ONLY Only support decompression OFF
MZ_BUILD_TEST Builds minizip test executable OFF
MZ_BUILD_UNIT_TEST Builds minizip unit test project OFF
MZ_BUILD_FUZZ_TEST Builds minizip fuzz executables OFF
MZ_CODE_COVERAGE Build with code coverage flags OFF

Contents

File(s) Description
minizip.c Sample application
mz_compat.* Minizip 1.x compatibility layer
mz.h Error codes and flags
mz_os* Platform specific file/utility functions
mz_crypt* Configuration specific crypto/hashing functions
mz_strm.* Stream interface
mz_strm_buf.* Buffered stream
mz_strm_bzip.* BZIP2 stream using libbzip2
mz_strm_libcomp.* Apple compression stream
mz_strm_lzma.* LZMA stream using liblzma
mz_strm_mem.* Memory stream
mz_strm_split.* Disk splitting stream
mz_strm_pkcrypt.* PKWARE traditional encryption stream
mz_strm_os* Platform specific file stream
mz_strm_wzaes.* WinZIP AES stream
mz_strm_zlib.* Deflate stream using zlib
mz_zip.* Zip format
mz_zip_rw.* Zip reader/writer

Third-Party Libraries

  • zlib written by Mark Adler and Jean-loup Gailly.
    • Not included in this repository
    • Or alternatively, zlib-ng by Hans Kristian Rosbach
  • BZIP2 written by Julian Seward.
  • liblzma written by Lasse Collin.
    • Modifications were made to support the ZIP file format specification
  • AES and SHA libraries of Brian Gladman.

Acknowledgments

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 on which this work is originally based on.

The ZIP format was defined by Phil Katz of PKWARE.