Skip to content

Commit

Permalink
Merge pull request #39 from ctabin/update-libzip
Browse files Browse the repository at this point in the history
Update to libzip 1.5.2
  • Loading branch information
ctabin authored May 5, 2019
2 parents ced24e1 + c869178 commit ff2b9ff
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OBJ=obj
LIB=lib
ZLIB_VERSION=1.2.11
ZLIB=$(LIB)/zlib-$(ZLIB_VERSION)
LIBZIP_VERSION=1.5.1
LIBZIP_VERSION=1.5.2
LIBZIP=$(LIB)/libzip-$(LIBZIP_VERSION)
LIBZIP_CMAKE=-DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF
CRYPTO_FLAGS=-lssl -lcrypto
Expand Down
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ libzippp is a simple basic C++ wrapper around the libzip library.
It is meant to be a portable and easy-to-use library for ZIP handling.

Compilation has been tested with:
- GCC 4.9.3 (GNU/Linux Gentoo)
- GCC 6.2.1 (GNU/Linux Debian)
- GCC 6.3.0 (GNU/Linux Debian)
- GCC 7.2.0 (GNU/Linux Debian)
- GCC 8.3.0 (GNU/Linux Debian)
- MS Visual Studio 2012 (Windows 7)

Underlying libraries:
- [ZLib](http://zlib.net) 1.2.11
- [libzip](http://www.nih.at/libzip) 1.5.1
- [libzip](http://www.nih.at/libzip) 1.5.2

# Compilation

Expand All @@ -27,13 +24,13 @@ Underlying libraries:
3. You may want to run the tests (optional): `make tests` (`libbz2-dev` package is needed to link statically)
4. Now you just have to include the src folder in your include path and
link against *libzippp.a* or *libzippp.so* (do not forget to also link
against libzip libraries in *lib/libzip-1.5.1/lib/.libs/*).
against libzip libraries in *lib/libzip-1.5.2/lib/.libs/*).
An example of compilation with g++:

```shell
g++ -I./lib/libzip-1.5.1/lib -I./src \
g++ -I./lib/libzip-1.5.2/lib -I./src \
main.cpp libzippp.a \
lib/libzip-1.5.1/lib/.libs/libzip.a \
lib/libzip-1.5.2/lib/.libs/libzip.a \
lib/zlib-1.2.11/libz.a
```

Expand Down Expand Up @@ -77,21 +74,22 @@ See [here](https://github.com/nih-at/libzip/blob/master/INSTALL.md) for more inf
<MSVS11>\Common7\Tools\VsDevCmd.bat
```

1. Download [libzip](http://www.nih.at/libzip/libzip-1.5.1.tar.gz) and [zlib](http://zlib.net/zlib1211.zip) sources and extract them in the 'lib' folder.
1. Download [libzip](http://www.nih.at/libzip/libzip-1.5.2.tar.gz) and [zlib](http://zlib.net/zlib1211.zip) sources and extract them in the 'lib' folder.
You should end up with the following structure:
```
libzippp/compile.bat
libzippp/lib/zlib-1.2.11
libzippp/lib/libzip-1.5.1
libzippp/lib/libzip-1.5.2
```
2. Apply the modifications described in libzippp/lib/libzip-1.5.2-windows.patch.

2. Execute the *compile.bat* (simply double-click on it). The compilation should
3. Execute the *compile.bat* (simply double-click on it). The compilation should
go without error.

3. You'll have a *dist* folder containing the *release* and *debug* folders
4. You'll have a *dist* folder containing the *release* and *debug* folders
where you can now execute the libzippp tests.

4. You can either use *libzippp.dll* and *libzippp.lib* to link dynamically the
5. You can either use *libzippp.dll* and *libzippp.lib* to link dynamically the
library or simply use *libzippp_static.lib* to link it statically. Unless you
also link zlib and libzippp statically, you'll need the dll packaged with
your executable.
Expand Down
6 changes: 4 additions & 2 deletions compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

SET vs2012devprompt=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat
SET zlib=lib\zlib-1.2.11
SET libzip=lib\libzip-1.5.1
SET libzip=lib\libzip-1.5.2

if not exist "%zlib%" goto error_zlib_not_found
if not exist "%libzip%" goto error_libzip_not_found
Expand Down Expand Up @@ -31,7 +31,7 @@ echo Compiling libzip...
cd "%libzip%"
mkdir build
cd "build"
cmake .. -G"Visual Studio 11" -DCMAKE_PREFIX_PATH="../../%zlib%/build/install"
cmake .. -G"Visual Studio 11" -DCMAKE_PREFIX_PATH="../../%zlib%/build/install" -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=ON -DENABLE_BZIP2=OFF -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF
if %ERRORLEVEL% GEQ 1 goto error_libzip
msbuild /P:Configuration=Debug ALL_BUILD.vcxproj
if %ERRORLEVEL% GEQ 1 goto error_libzip
Expand Down Expand Up @@ -62,6 +62,7 @@ if exist "dist\libzippp_static.lib" goto end
mkdir "dist"
cd "dist"
mkdir release
copy ..\src\libzippp.h release
copy ..\build\Release\libzippp_shared_test.exe release
copy ..\build\Release\libzippp_static_test.exe release
copy ..\build\Release\libzippp.dll release
Expand All @@ -70,6 +71,7 @@ copy ..\build\Release\libzippp_static.lib release
copy ..\%zlib%\build\Release\zlib.dll release
copy ..\%libzip%\build\lib\Release\zip.dll release
mkdir debug
copy ..\src\libzippp.h debug
copy ..\build\Debug\libzippp_shared_test.exe debug
copy ..\build\Debug\libzippp_static_test.exe debug
copy ..\build\Debug\libzippp.dll debug
Expand Down
24 changes: 24 additions & 0 deletions lib/libzip-1.5.2-windows.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff -u libzip-1.5.2/lib/zip_crypto_win.c libzip-1.5.2-win/lib/zip_crypto_win.c
--- libzip-1.5.2/lib/zip_crypto_win.c 2019-03-12 12:44:02.000000000 +0100
+++ libzip-1.5.2-win/lib/zip_crypto_win.c 2019-05-05 21:41:01.203275000 +0200
@@ -80,7 +80,7 @@
*/

#if !defined(WINCE) && !defined(__MINGW32__)
-#define HAS_BCRYPTDERIVEKEYPBKDF2
+//#define HAS_BCRYPTDERIVEKEYPBKDF2
#endif

#ifdef HAS_BCRYPTDERIVEKEYPBKDF2
diff -u libzip-1.5.2/lib/zip_source_winzip_aes_encode.c libzip-1.5.2-win/lib/zip_source_winzip_aes_encode.c
--- libzip-1.5.2/lib/zip_source_winzip_aes_encode.c 2019-03-12 12:44:02.000000000 +0100
+++ libzip-1.5.2-win/lib/zip_source_winzip_aes_encode.c 2019-05-05 21:51:31.213545000 +0200
@@ -163,7 +163,7 @@
/* TODO: return partial read? */
return -1;
}
- buffer_n += _zip_buffer_read(ctx->buffer, data + ret, length - (zip_uint64_t)ret);
+ buffer_n += _zip_buffer_read(ctx->buffer, ((size_t)data) + ret, length - (zip_uint64_t)ret);
}

return (zip_int64_t)(buffer_n + (zip_uint64_t)ret);

0 comments on commit ff2b9ff

Please sign in to comment.