Commit a4ce93c6 authored by Roy Marmelstein's avatar Roy Marmelstein

Updating minizip

parent fe792d1d
This diff is collapsed.
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)
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.
\ No newline at end of file
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)
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
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
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
\ No newline at end of file
This diff is collapsed.
......@@ -42,7 +42,7 @@ int entropy_fun(unsigned char buf[], unsigned int len)
int rlen = 0;
if (frand != -1)
{
rlen = (int)read(frand, buf, len);
rlen = read(frand, buf, len);
close(frand);
}
return rlen;
......
#ifndef _ENTROPY_FUN_H
#define _ENTROPY_FUN_H
#if defined(__cplusplus)
extern "C"
{
#endif
#ifndef _ENTROPY_FUN_H
#define _ENTROPY_FUN_H
#if defined(__cplusplus)
extern "C"
{
#endif
int entropy_fun(unsigned char buf[], unsigned int len);
#if defined(__cplusplus)
}
#endif
#endif
#if defined(__cplusplus)
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([minizip], [1.2.8], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
AC_MSG_CHECKING([whether to build example programs])
AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs]))
AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes])
if test "$enable_demos" = yes
then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
case "${host}" in
*-mingw* | mingw*)
WIN32="yes"
;;
*)
;;
esac
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AC_SUBST([HAVE_UNISTD_H], [0])
AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], [])
AC_CONFIG_FILES([Makefile minizip.pc])
AC_OUTPUT
This diff is collapsed.
......@@ -118,7 +118,7 @@ static voidpf file_build_ioposix(FILE *file, const char *filename)
return NULL;
ioposix = (FILE_IOPOSIX*)malloc(sizeof(FILE_IOPOSIX));
ioposix->file = file;
ioposix->filenameLength = (int)strlen(filename) + 1;
ioposix->filenameLength = strlen(filename) + 1;
ioposix->filename = (char*)malloc(ioposix->filenameLength * sizeof(char));
strncpy(ioposix->filename, filename, ioposix->filenameLength);
return (voidpf)ioposix;
......@@ -176,7 +176,7 @@ static voidpf ZCALLBACK fopendisk64_file_func (voidpf opaque, voidpf stream, int
strncpy(diskFilename, ioposix->filename, ioposix->filenameLength);
for (i = ioposix->filenameLength - 1; i >= 0; i -= 1)
{
if (diskFilename[i] != '.')
if (diskFilename[i] != '.')
continue;
snprintf(&diskFilename[i], ioposix->filenameLength - i, ".z%02d", number_disk + 1);
break;
......@@ -201,7 +201,7 @@ static voidpf ZCALLBACK fopendisk_file_func (voidpf opaque, voidpf stream, int n
strncpy(diskFilename, ioposix->filename, ioposix->filenameLength);
for (i = ioposix->filenameLength - 1; i >= 0; i -= 1)
{
if (diskFilename[i] != '.')
if (diskFilename[i] != '.')
continue;
snprintf(&diskFilename[i], ioposix->filenameLength - i, ".z%02d", number_disk + 1);
break;
......
......@@ -59,7 +59,7 @@
#ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else
# ifdef HAS_STDINT_H
# ifdef HAVE_STDINT_H
# include "stdint.h"
typedef uint64_t ZPOS64_T;
# else
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment