Skip to content

Commit

Permalink
Updating minizip
Browse files Browse the repository at this point in the history
  • Loading branch information
marmelroy committed Jan 14, 2016
1 parent fe792d1 commit a4ce93c
Show file tree
Hide file tree
Showing 49 changed files with 9,433 additions and 5,513 deletions.
188 changes: 96 additions & 92 deletions Zip.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

140 changes: 140 additions & 0 deletions Zip/minizip/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
More changes since 1.1
- Added support for AE-2 zip files
- Fixed error in AE-1 not testing CRC32

Credits

Steven Christy

Changes since 1.1
- Added PKZIP spanning support
- Added AES encryption support
- Added I/O buffering
- Clean up & changed unzLocateFile to support custom comparison function
- Clean up, removed zipRemoveExtraInfoBlock

Credits

Nathan Moinvaziri

Change in 1.1
- Added ZIP64 support for unzip ( by Even Rouault )
- Added ZIP64 support for zip ( by Mathias Svensson )
- Reverted some changed that Even Rouault did.
- Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
- Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
- Added BZIP Compress method for zip
- Did some refactoring and code cleanup

Credits

Gilles Vollant - Original MiniZip author
Even Rouault - ZIP64 unzip Support

2007-2008
- Addition of cpl_unzGetCurrentFileZStreamPos
- Decoration of symbol names unz* -> cpl_unz*
- Remove old C style function prototypes
- Add unzip support for ZIP64

Daniel Borca - BZip Compression method support in unzip
Mathias Svensson - ZIP64 zip support ( http://result42.com )

Oct-2009 unzip.c
- Removed cpl_* from symbol names
- Fixed problem if uncompressed size was > 4G and compressed size was <4G
should only read the compressed/uncompressed size from the Zip64 format if
the size from normal header was 0xffffffff
- Applied some bug fixes from patches received from Gilles Vollant
- Applied support to unzip files with compression method BZIP2 (bzip2 lib is required)
Patch created by Daniel Borca

Oct-2009 zip.c
- Remove old C style function prototypes
- Added Zip64 Support when creating new file archives
- Did some code cleanup and refactoring to get better overview of some functions.
- Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
It is used when recreting zip archive with RAW when deleting items from a zip.
ZIP64 data is automaticly added to items that needs it, and existing ZIP64
data need to be removed.
- Added support for BZIP2 as compression mode (bzip2 lib is required)

Oct-2009 ioapi.x
- Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux.
- Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
More if/def section may be needed to support other platforms
- Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
(but you should use iowin32.c for windows instead)

Change in 1.01e (12 feb 05)
- Fix in zipOpen2 for globalcomment (Rolf Kalbermatter)
- Fix possible memory leak in unzip.c (Zoran Stevanovic)

Change in 1.01b (20 may 04)
- Integrate patch from Debian package (Mark Brown)
- Add tools mztools from Xavier Roche

Change in 1.01 (8 may 04)
- Fix buffer overrun risk in unzip.c (Xavier Roche)
- Fix a minor buffer insecurity in minizip.c (Mike Whittaker)

Change in 1.00: (10 sept 03)
- Rename to 1.00
- Cosmetic code change

Change in 0.22: (19 May 03)
- Crypting support (unless you define NOCRYPT)
- Append file in existing zipfile

Change in 0.21: (10 Mar 03)
- Bug fixes

Change in 0.17: (27 Jan 02)
- Bug fixes

Change in 0.16: (19 Jan 02)
- Support of ioapi for virtualize zip file access

Change in 0.15: (19 Mar 98)
- Fix memory leak in minizip.c

Change in 0.14: (10 Mar 98)
- Fix bugs in minizip.c sample for zipping big file
- Fix problem in month in date handling
- Fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for comment handling

Change in 0.13: (6 Mar 98)
- Fix bugs in zip.c
- Add real minizip sample

Change in 0.12: (4 Mar 98)
- Add zip.c and zip.h for creates .zip file
- Fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
- Fix miniunz.c for file without specific record for directory

Change in 0.11: (3 Mar 98)
- Fix bug in unzGetCurrentFileInfo for get extra field and comment
- Enhance miniunz sample, remove the bad unztst.c sample

Change in 0.10: (2 Mar 98)
- Fix bug in unzReadCurrentFile
- Rename unzip* to unz* function and structure
- Remove Windows-like hungary notation variable name
- Modify some structure in unzip.h
- Add somes comment in source
- Remove unzipGetcCurrentFile function
- Replace ZUNZEXPORT by ZEXPORT
- Add unzGetLocalExtrafield for get the local extrafield info
- Add a new sample, miniunz.c

Change in 0.4: (25 Feb 98)
- Suppress the type unzipFileInZip.
Only on file in the zipfile can be open at the same time
- Fix somes typo in code
- Added tm_unz structure in unzip_file_info (date/time in readable format)

Change unknown?
- Added unzGetOffset (RX '2004)
- Added unzGetFilePos & unzGoToFilePos (Ryan Haksi)
- Added unzGetCurrentFileZStreamPos64 (GDAL)

17 changes: 17 additions & 0 deletions Zip/minizip/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Condition of use and distribution are the same as zlib:

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
37 changes: 37 additions & 0 deletions Zip/minizip/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CC=cc
CFLAGS=-O -I../.. -DHAVE_AES

UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a libaes.a
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a libaes.a
TEST_FILES = test.zip readme.old readme.txt

.c.o:
$(CC) -c $(CFLAGS) $*.c

all: miniunz minizip

libaes.a:
cd aes; $(MAKE) $(MFLAGS)

miniunz: $(UNZ_OBJS) libaes.a
$(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)

minizip: $(ZIP_OBJS) libaes.a
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)

.PHONY: test clean

test: miniunz minizip
@rm -f $(TEST_FILES)
@cp README.md readme.txt
@touch -t 200712301223.44 readme.txt
./minizip test.zip readme.txt
./miniunz -l test.zip
mv readme.txt readme.old
./miniunz test.zip
@diff -q README.md readme.txt || echo "Test failed: files differ"
@[[ "$$(stat -c %Y readme.txt)" = "$$(stat -c %Y readme.old)" ]] || echo "Test failed: timestamp not preserved"
@rm -f $(TEST_FILES)

clean:
/bin/rm -f *.o *~ minizip miniunz $(TEST_FILES)
43 changes: 43 additions & 0 deletions Zip/minizip/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
lib_LTLIBRARIES = libminizip.la

if COND_DEMOS
bin_PROGRAMS = miniunzip minizip
endif

zlib_top_srcdir = $(top_srcdir)/../..
zlib_top_builddir = $(top_builddir)/../..

AM_CPPFLAGS = -I$(zlib_top_srcdir)
AM_LDFLAGS = -L$(zlib_top_builddir)

if WIN32
iowin32_src = iowin32.c
iowin32_h = iowin32.h
endif

libminizip_la_SOURCES = \
ioapi.c \
unzip.c \
zip.c \
${iowin32_src}

libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz

minizip_includedir = $(includedir)/minizip
minizip_include_HEADERS = \
crypt.h \
ioapi.h \
unzip.h \
zip.h \
${iowin32_h}

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = minizip.pc

EXTRA_PROGRAMS = miniunzip minizip

miniunzip_SOURCES = miniunz.c
miniunzip_LDADD = libminizip.la

minizip_SOURCES = minizip.c
minizip_LDADD = libminizip.la -lz
81 changes: 81 additions & 0 deletions Zip/minizip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Minizip zlib contribution that includes:

- AES encryption
- I/O buffering
- PKWARE disk spanning
- Visual Studio 2008 project files

It also has the latest bug fixes that having been found all over the internet including the minizip forum and zlib developer's mailing list.

*AES Encryption*

+ Requires #define HAVE_AES
+ Requires AES library files

When zipping with a password it will always use AES 256-bit encryption.
When unzipping it will use AES decryption only if necessary.

*I/O Buffering*

Improves I/O performance by buffering read and write operations.
```
zlib_filefunc64_def filefunc64 = {0};
ourbuffer_t buffered = {0};
fill_win32_filefunc64(&buffered->filefunc64);
fill_buffer_filefunc64(&filefunc64, buffered);
unzOpen2_64(filename, &filefunc64)
```

*PKWARE disk spanning*

To create an archive with multiple disks use zipOpen3_64 supplying a disk_size value in bytes.

```
extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append,
ZPOS64_T disk_size, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
```
The central directory is the only data stored in the .zip and doesn't follow disk_size restrictions.

When unzipping it will automatically determine when in needs to span disks.

*I/O Memory*

To unzip from a zip file in memory use fill_memory_filefunc and supply a proper ourmemory_t structure.
```
zlib_filefunc_def filefunc32 = {0};
ourmemory_t unzmem = {0};
unzmem.size = bufsize;
unzmem.base = (char *)malloc(unzmem.size);
memcpy(unzmem.base, buffer, unzmem.size);
fill_memory_filefunc(&filefunc32, &unzmem);
unzOpen2("__notused__", &filefunc32);
```

To create a zip file in memory use fill_memory_filefunc and supply a proper ourmemory_t structure. It is important
not to forget to free zipmem->base when finished. If grow is set, zipmem->base will expand to fit the size of the zip.
If grow is not set be sure to fill out zipmem.base and zipmem.size.

```
zlib_filefunc_def filefunc32 = {0};
ourmemory_t zipmem = {0};
zipmem.grow = 1;
fill_memory_filefunc(&filefunc32, &zipmem);
zipOpen3("__notused__", APPEND_STATUS_CREATE, 0, 0, &filefunc32);
```

*BZIP2*

+ Requires #define HAVE_BZIP2
+ Requires BZIP2 library

*Windows RT*

+ Requires #define IOWIN32_USING_WINRT_API
19 changes: 19 additions & 0 deletions Zip/minizip/aes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CC=cc
CFLAGS=-O -DHAVE_AES
OBJS=aescrypt.o aeskey.o aestab.o entropy.o fileenc.o hmac.o prng.o pwd2key.o sha1.o
ARFLAGS=rv

.c.o:
$(CC) -c $(CFLAGS) $*.c

libaes.a: $(OBJS)
$(ECHO) $(AR) $(ARFLAGS) ../libaes.a $?
$(AR) $(ARFLAGS) ../libaes.a $?
$(RANLIB) ../libaes.a

all: libaes.a

.PHONY: clean

clean:
rm *.o *.a
Loading

0 comments on commit a4ce93c

Please sign in to comment.