[DO-984] add-zlib-recipe (!4)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/4
This commit is contained in:
51
recipes/zlib/all/conandata.yml
Normal file
51
recipes/zlib/all/conandata.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
sources:
|
||||
"1.3.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/zlib"
|
||||
branch: "v1.3.1"
|
||||
"1.3":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/zlib"
|
||||
branch: "v1.3"
|
||||
"1.2.13":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/zlib"
|
||||
branch: "v1.2.13"
|
||||
"1.2.12":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/zlib"
|
||||
branch: "v1.2.12"
|
||||
"1.2.11":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/zlib"
|
||||
branch: "v1.2.11"
|
||||
patches:
|
||||
"1.3.1":
|
||||
- patch_file: "patches/1.3.1/0001-fix-cmake.patch"
|
||||
patch_description: "separate static/shared builds, disable debug suffix"
|
||||
patch_type: "conan"
|
||||
"1.3":
|
||||
- patch_file: "patches/1.3/0001-fix-cmake.patch"
|
||||
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
|
||||
patch_type: "conan"
|
||||
"1.2.13":
|
||||
- patch_file: "patches/1.2.13/0001-Fix-cmake.patch"
|
||||
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
|
||||
patch_type: "conan"
|
||||
"1.2.12":
|
||||
- patch_file: "patches/1.2.x/0001-fix-cmake.patch"
|
||||
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/1.2.x/0004-Fix-a-bug-when-getting-a-gzip-header-extra-field-wit.patch"
|
||||
patch_description: "CVE-2022-37434: Fix a bug when getting a gzip header extra field with inflate()"
|
||||
patch_type: "vulnerability"
|
||||
patch_source: "https://github.com/madler/zlib/commit/eff308af425b67093bab25f80f1ae950166bece1"
|
||||
sha256: "15e3c177dc2a034a22e02490a97ba5b1719aae3f8129a06c16d727b661d1650f"
|
||||
- patch_file: "patches/1.2.x/0005-Fix-extra-field-processing-bug-that-dereferences-NUL.patch"
|
||||
patch_description: "CVE-2022-37434: Fix extra field processing bug that dereferences NULL state->head"
|
||||
patch_type: "vulnerability"
|
||||
patch_source: "https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d"
|
||||
sha256: "cdd69eb3251728b1875c8ecae6427b50aa750b4045ef984ab79b6c07b7e6dd3a"
|
||||
"1.2.11":
|
||||
- patch_file: "patches/1.2.x/0001-fix-cmake.patch"
|
||||
patch_description: "separate static/shared builds, disable debug suffix, disable building examples"
|
||||
patch_type: "conan"
|
||||
- patch_file: "patches/1.2.x/0003-gzguts-fix-widechar-condition.patch"
|
||||
patch_description: "fix condition for WIDECHAR usage"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/madler/zlib/issues/268"
|
||||
114
recipes/zlib/all/conanfile.py
Normal file
114
recipes/zlib/all/conanfile.py
Normal file
@@ -0,0 +1,114 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, load, replace_in_file, save
|
||||
from conan.tools.scm import Version, Git
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class ZlibConan(ConanFile):
|
||||
name = "zlib"
|
||||
package_type = "library"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://zlib.net"
|
||||
license = "Zlib"
|
||||
description = ("A Massively Spiffy Yet Delicately Unobtrusive Compression Library "
|
||||
"(Also Free, Not to Mention Unencumbered by Patents)")
|
||||
topics = ("zlib", "compression")
|
||||
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
@property
|
||||
def _is_mingw(self):
|
||||
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def source(self):
|
||||
#get(self, **self.conan_data["sources"][self.version],
|
||||
# destination=self.source_folder, strip_root=True)
|
||||
git = Git(self)
|
||||
sources = self.conan_data["sources"][self.version]
|
||||
clone_args = ['--depth', '1', '--branch', sources["branch"]]
|
||||
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["SKIP_INSTALL_ALL"] = False
|
||||
tc.variables["SKIP_INSTALL_LIBRARIES"] = False
|
||||
tc.variables["SKIP_INSTALL_HEADERS"] = False
|
||||
tc.variables["SKIP_INSTALL_FILES"] = True
|
||||
# Correct for misuse of "${CMAKE_INSTALL_PREFIX}/" in CMakeLists.txt
|
||||
tc.variables["INSTALL_LIB_DIR"] = "lib"
|
||||
tc.variables["INSTALL_INC_DIR"] = "include"
|
||||
tc.variables["ZLIB_BUILD_EXAMPLES"] = False
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
apply_conandata_patches(self)
|
||||
|
||||
is_apple_clang12 = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) >= "12.0"
|
||||
if not is_apple_clang12:
|
||||
for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:
|
||||
filepath = os.path.join(self.source_folder, filename)
|
||||
replace_in_file(self, filepath,
|
||||
'#ifdef HAVE_UNISTD_H '
|
||||
'/* may be set to #if 1 by ./configure */',
|
||||
'#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')
|
||||
replace_in_file(self, filepath,
|
||||
'#ifdef HAVE_STDARG_H '
|
||||
'/* may be set to #if 1 by ./configure */',
|
||||
'#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def _extract_license(self):
|
||||
tmp = load(self, os.path.join(self.source_folder, "zlib.h"))
|
||||
license_contents = tmp[2:tmp.find("*/", 1)]
|
||||
return license_contents
|
||||
|
||||
def package(self):
|
||||
save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license())
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_file_name", "ZLIB")
|
||||
self.cpp_info.set_property("cmake_target_name", "ZLIB::ZLIB")
|
||||
self.cpp_info.set_property("pkg_config_name", "zlib")
|
||||
if self.settings.os == "Windows" and not self._is_mingw:
|
||||
libname = "zdll" if self.options.shared else "zlib"
|
||||
else:
|
||||
libname = "z"
|
||||
self.cpp_info.libs = [libname]
|
||||
|
||||
self.cpp_info.names["cmake_find_package"] = "ZLIB"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "ZLIB"
|
||||
118
recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch
Normal file
118
recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch
Normal file
@@ -0,0 +1,118 @@
|
||||
From 9a709a43549fbe23ca41eeb450d4c71e3b78c8c4 Mon Sep 17 00:00:00 2001
|
||||
From: Mikhail Lappo <miklelappo@gmail.com>
|
||||
Date: Fri, 14 Oct 2022 13:29:56 +0200
|
||||
Subject: [PATCH] Fix cmake
|
||||
|
||||
---
|
||||
CMakeLists.txt | 33 +++++++++++++++++++++------------
|
||||
1 file changed, 21 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index b412dc7..a5284ed 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-cmake_minimum_required(VERSION 2.4.4)
|
||||
+cmake_minimum_required(VERSION 3.0) # it's important to have https://cmake.org/cmake/help/latest/policy/CMP0042.html#policy:CMP0042
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
|
||||
project(zlib C)
|
||||
@@ -57,7 +57,6 @@ endif()
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
if(MSVC)
|
||||
- set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -80,7 +79,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
||||
#============================================================================
|
||||
@@ -120,7 +119,7 @@ set(ZLIB_SRCS
|
||||
zutil.c
|
||||
)
|
||||
|
||||
-if(NOT MINGW)
|
||||
+if(MSVC)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
@@ -131,7 +130,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
|
||||
-if(MINGW)
|
||||
+if(WIN32 AND NOT MSVC)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
@@ -145,12 +144,15 @@ if(MINGW)
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
-endif(MINGW)
|
||||
+endif()
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
+else()
|
||||
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
+endif()
|
||||
|
||||
if(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
@@ -163,19 +165,24 @@ if(NOT CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
-if(UNIX)
|
||||
+if(WIN32 AND NOT MINGW)
|
||||
+ if(BUILD_SHARED_LIBS)
|
||||
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
|
||||
+ endif()
|
||||
+else()
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE)
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
-elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
+endif()
|
||||
+if(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
- install(TARGETS zlib zlibstatic
|
||||
+ install(TARGETS zlib
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
@@ -194,6 +201,7 @@ endif()
|
||||
# Example binaries
|
||||
#============================================================================
|
||||
|
||||
+if(0)
|
||||
add_executable(example test/example.c)
|
||||
target_link_libraries(example zlib)
|
||||
add_test(example example)
|
||||
@@ -211,3 +219,4 @@ if(HAVE_OFF64_T)
|
||||
target_link_libraries(minigzip64 zlib)
|
||||
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
+endif()
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
104
recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch
Normal file
104
recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch
Normal file
@@ -0,0 +1,104 @@
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-cmake_minimum_required(VERSION 2.4.4)
|
||||
+cmake_minimum_required(VERSION 3.0) # it's important to have https://cmake.org/cmake/help/latest/policy/CMP0042.html#policy:CMP0042
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
|
||||
project(zlib C)
|
||||
@@ -60,7 +60,6 @@ endif()
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
if(MSVC)
|
||||
- set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -83,7 +82,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
||||
#============================================================================
|
||||
@@ -123,7 +122,7 @@ set(ZLIB_SRCS
|
||||
zutil.c
|
||||
)
|
||||
|
||||
-if(NOT MINGW)
|
||||
+if(MSVC)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
@@ -167,7 +166,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
|
||||
-if(MINGW)
|
||||
+if(WIN32 AND NOT MSVC)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
@@ -181,12 +180,15 @@ if(MINGW)
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
-endif(MINGW)
|
||||
+endif()
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
+else()
|
||||
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
+endif()
|
||||
|
||||
if(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
@@ -199,19 +201,24 @@ if(NOT CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
-if(UNIX)
|
||||
+if(WIN32 AND NOT MINGW)
|
||||
+ if(BUILD_SHARED_LIBS)
|
||||
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
|
||||
+ endif()
|
||||
+else()
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE)
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
-elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
+endif()
|
||||
+if(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
- install(TARGETS zlib zlibstatic
|
||||
+ install(TARGETS zlib
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
@@ -230,6 +237,7 @@ endif()
|
||||
# Example binaries
|
||||
#============================================================================
|
||||
|
||||
+if(0)
|
||||
add_executable(example test/example.c)
|
||||
target_link_libraries(example zlib)
|
||||
add_test(example example)
|
||||
@@ -247,3 +255,4 @@ if(HAVE_OFF64_T)
|
||||
target_link_libraries(minigzip64 zlib)
|
||||
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
+endif()
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/gzguts.h b/gzguts.h
|
||||
index 990a4d2..6378d46 100644
|
||||
--- a/gzguts.h
|
||||
+++ b/gzguts.h
|
||||
@@ -39,7 +39,7 @@
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
-#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
+#if defined(_WIN32)
|
||||
# define WIDECHAR
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Adler <fork@madler.net>
|
||||
Date: Sat, 30 Jul 2022 15:51:11 -0700
|
||||
Subject: [PATCH] Fix a bug when getting a gzip header extra field with
|
||||
inflate().
|
||||
|
||||
If the extra field was larger than the space the user provided with
|
||||
inflateGetHeader(), and if multiple calls of inflate() delivered
|
||||
the extra header data, then there could be a buffer overflow of the
|
||||
provided space. This commit assures that provided space is not
|
||||
exceeded.
|
||||
---
|
||||
inflate.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/inflate.c b/inflate.c
|
||||
index 7be8c63..7a72897 100644
|
||||
--- a/inflate.c
|
||||
+++ b/inflate.c
|
||||
@@ -763,9 +763,10 @@ int flush;
|
||||
copy = state->length;
|
||||
if (copy > have) copy = have;
|
||||
if (copy) {
|
||||
+ len = state->head->extra_len - state->length;
|
||||
if (state->head != Z_NULL &&
|
||||
- state->head->extra != Z_NULL) {
|
||||
- len = state->head->extra_len - state->length;
|
||||
+ state->head->extra != Z_NULL &&
|
||||
+ len < state->head->extra_max) {
|
||||
zmemcpy(state->head->extra + len, next,
|
||||
len + copy > state->head->extra_max ?
|
||||
state->head->extra_max - len : copy);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001
|
||||
From: Mark Adler <fork@madler.net>
|
||||
Date: Mon, 8 Aug 2022 10:50:09 -0700
|
||||
Subject: [PATCH] Fix extra field processing bug that dereferences NULL
|
||||
state->head.
|
||||
|
||||
The recent commit to fix a gzip header extra field processing bug
|
||||
introduced the new bug fixed here.
|
||||
---
|
||||
inflate.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/inflate.c b/inflate.c
|
||||
index 7a72897..2a3c4fe 100644
|
||||
--- a/inflate.c
|
||||
+++ b/inflate.c
|
||||
@@ -763,10 +763,10 @@ int flush;
|
||||
copy = state->length;
|
||||
if (copy > have) copy = have;
|
||||
if (copy) {
|
||||
- len = state->head->extra_len - state->length;
|
||||
if (state->head != Z_NULL &&
|
||||
state->head->extra != Z_NULL &&
|
||||
- len < state->head->extra_max) {
|
||||
+ (len = state->head->extra_len - state->length) <
|
||||
+ state->head->extra_max) {
|
||||
zmemcpy(state->head->extra + len, next,
|
||||
len + copy > state->head->extra_max ?
|
||||
state->head->extra_max - len : copy);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
81
recipes/zlib/all/patches/1.3.1/0001-fix-cmake.patch
Normal file
81
recipes/zlib/all/patches/1.3.1/0001-fix-cmake.patch
Normal file
@@ -0,0 +1,81 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 15ceebe..2f08574 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -59,7 +59,6 @@ endif()
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
if(MSVC)
|
||||
- set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -122,7 +121,7 @@ set(ZLIB_SRCS
|
||||
zutil.c
|
||||
)
|
||||
|
||||
-if(NOT MINGW)
|
||||
+if(MSVC)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
@@ -133,7 +132,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
|
||||
-if(MINGW)
|
||||
+if(WIN32 AND NOT MSVC)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
@@ -147,14 +146,16 @@ if(MINGW)
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
-endif(MINGW)
|
||||
+endif()
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
+else()
|
||||
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
+endif()
|
||||
|
||||
if(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
@@ -167,19 +168,25 @@ if(NOT CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
-if(UNIX)
|
||||
+if(WIN32 AND NOT MINGW)
|
||||
+ if(BUILD_SHARED_LIBS)
|
||||
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
|
||||
+ endif()
|
||||
+else()
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
-elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
+endif()
|
||||
+if(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
|
||||
endif()
|
||||
|
||||
+
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
- install(TARGETS zlib zlibstatic
|
||||
+ install(TARGETS zlib
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
92
recipes/zlib/all/patches/1.3/0001-fix-cmake.patch
Normal file
92
recipes/zlib/all/patches/1.3/0001-fix-cmake.patch
Normal file
@@ -0,0 +1,92 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 7f1b69f..618ea02 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -57,7 +57,6 @@ endif()
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
if(MSVC)
|
||||
- set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -120,7 +119,7 @@ set(ZLIB_SRCS
|
||||
zutil.c
|
||||
)
|
||||
|
||||
-if(NOT MINGW)
|
||||
+if(MSVC)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
@@ -131,7 +130,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
|
||||
-if(MINGW)
|
||||
+if(WIN32 AND NOT MSVC)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
@@ -145,12 +144,16 @@ if(MINGW)
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
-endif(MINGW)
|
||||
+endif()
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
+else()
|
||||
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
+endif()
|
||||
|
||||
if(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
@@ -163,19 +166,24 @@ if(NOT CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
-if(UNIX)
|
||||
+if(WIN32 AND NOT MINGW)
|
||||
+ if(BUILD_SHARED_LIBS)
|
||||
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
|
||||
+ endif()
|
||||
+else()
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE)
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
-elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
+endif()
|
||||
+if(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
- install(TARGETS zlib zlibstatic
|
||||
+ install(TARGETS zlib
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
@@ -193,7 +201,7 @@ endif()
|
||||
#============================================================================
|
||||
# Example binaries
|
||||
#============================================================================
|
||||
-
|
||||
+if(0)
|
||||
add_executable(example test/example.c)
|
||||
target_link_libraries(example zlib)
|
||||
add_test(example example)
|
||||
@@ -211,3 +219,4 @@ if(HAVE_OFF64_T)
|
||||
target_link_libraries(minigzip64 zlib)
|
||||
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
+endif()
|
||||
7
recipes/zlib/all/test_package/CMakeLists.txt
Normal file
7
recipes/zlib/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
|
||||
27
recipes/zlib/all/test_package/conanfile.py
Normal file
27
recipes/zlib/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run, cross_building
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
if not cross_building(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self) and not cross_building(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
32
recipes/zlib/all/test_package/test_package.c
Normal file
32
recipes/zlib/all/test_package/test_package.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
int main(void) {
|
||||
char buffer_in [32] = {"Conan Package Manager"};
|
||||
char buffer_out [32] = {0};
|
||||
|
||||
z_stream defstream;
|
||||
defstream.zalloc = Z_NULL;
|
||||
defstream.zfree = Z_NULL;
|
||||
defstream.opaque = Z_NULL;
|
||||
defstream.avail_in = (uInt) strlen(buffer_in);
|
||||
defstream.next_in = (Bytef *) buffer_in;
|
||||
defstream.avail_out = (uInt) sizeof(buffer_out);
|
||||
defstream.next_out = (Bytef *) buffer_out;
|
||||
|
||||
deflateInit(&defstream, Z_BEST_COMPRESSION);
|
||||
deflate(&defstream, Z_FINISH);
|
||||
deflateEnd(&defstream);
|
||||
|
||||
printf("Compressed size is: %lu\n", strlen(buffer_in));
|
||||
printf("Compressed string is: %s\n", buffer_in);
|
||||
printf("Compressed size is: %lu\n", strlen(buffer_out));
|
||||
printf("Compressed string is: %s\n", buffer_out);
|
||||
|
||||
printf("ZLIB VERSION: %s\n", zlibVersion());
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
10
recipes/zlib/all/test_v1_package/CMakeLists.txt
Normal file
10
recipes/zlib/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
|
||||
16
recipes/zlib/all/test_v1_package/conanfile.py
Normal file
16
recipes/zlib/all/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
self.run(os.path.join("bin", "test_package"), run_environment=True)
|
||||
11
recipes/zlib/config.yml
Normal file
11
recipes/zlib/config.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
versions:
|
||||
"1.3.1":
|
||||
folder: all
|
||||
"1.3":
|
||||
folder: all
|
||||
"1.2.13":
|
||||
folder: all
|
||||
"1.2.12":
|
||||
folder: all
|
||||
"1.2.11":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user