From b36c18de95c500fa5d332950f9a4ac47b726dad5 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Wed, 13 Jul 2022 23:13:45 +0400 Subject: [PATCH] Require API/ABI compatible zlib minizip version `src/minizip/` is the original zlib version[0], but minizip-ng[1] exists and some operating systems package the latter instead of the former. minizip-ng changed API/ABI starting with version 2.0.0; building libdigidocpp against minizip-ng currently works but crashes at runtime, as observed on OpenBSD 7.1 packaging minizip 3.0.3: ``` $ digidoc-tool sign /tmp/hello.asice Version digidoc-tool version: 3.14.8.0 libdigidocpp version: 3.14.8.0 libc++abi: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc Abort trap (core dumped) ``` Relevant backtrace: ``` at .../src/ASiContainer.cpp:83 (gdb) fr 14 112 string fileName(fileInfo.size_filename, 0); (gdb) p fileInfo.size_filename $1 = 12374034502228 ``` No wonder allocating 11.25 TB fails. To fix this, require `<2.0.0`, effectively zlib minizip. This is the exact same approach I already employed to fix Telegram's Desktop client[2]. 0: https://github.com/madler/zlib 1: https://github.com/zlib-ng/minizip-ng 2: https://github.com/desktop-app/cmake_helpers/pull/156 Signed-off-by: Klemens Nanni --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83130e16..38b7df8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,10 +51,10 @@ find_package(Threads) find_package(XmlSecurityC REQUIRED) find_package(XSD 4.0 REQUIRED) find_package(ZLIB REQUIRED) -find_package(MiniZip QUIET) +find_package(MiniZip 1 QUIET) # version range (0...<2.0.0) requires CMake>=3.19 if(UNIX AND NOT APPLE) find_package(PkgConfig) - pkg_check_modules(MINIZIP minizip IMPORTED_TARGET) + pkg_check_modules(MINIZIP minizip IMPORTED_TARGET minizip<2.0.0) endif() find_package(SWIG) find_package(JNI)