Skip to content

Commit a601a58

Browse files
committed
Bug#37069890 Upgrade ZLIB sources to the new version 1.3.1
1 parent af5e112 commit a601a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2221
-2121
lines changed

cdk/extra/zlib/CMakeLists.txt

Lines changed: 119 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,28 @@
1-
# Copyright (c) 2006, 2024, Oracle and/or its affiliates.
2-
#
3-
# This program is free software; you can redistribute it and/or modify
4-
# it under the terms of the GNU General Public License, version 2.0,
5-
# as published by the Free Software Foundation.
6-
#
7-
# This program is designed to work with certain software (including
8-
# but not limited to OpenSSL) that is licensed under separate terms, as
9-
# designated in a particular file or component or in included license
10-
# documentation. The authors of MySQL hereby grant you an additional
11-
# permission to link the program and your derivative works with the
12-
# separately licensed software that they have either included with
13-
# the program or referenced in the documentation.
14-
#
15-
# This program is distributed in the hope that it will be useful, but
16-
# WITHOUT ANY WARRANTY; without even the implied warranty of
17-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18-
# the GNU General Public License, version 2.0, for more details.
19-
#
20-
# You should have received a copy of the GNU General Public License
21-
# along with this program; if not, write to the Free Software Foundation, Inc.,
22-
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23-
24-
cmake_minimum_required(VERSION 2.4.4)
1+
cmake_minimum_required(VERSION 3.5)
2+
cmake_policy(SET CMP0048 NEW) # allow VERSION specification in project()
253
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
264

27-
set(VERSION "1.2.13")
5+
# project(zlib C)
286

29-
IF(POLICY CMP0048)
30-
CMAKE_POLICY(SET CMP0048 NEW)
31-
project(zlib VERSION ${VERSION} LANGUAGES C)
32-
ELSE()
33-
project(zlib C)
34-
ENDIF()
7+
set(VERSION "1.3.1")
358

36-
IF(POLICY CMP0075)
37-
CMAKE_POLICY(SET CMP0075 OLD)
38-
ENDIF()
9+
project(zlib VERSION ${VERSION} LANGUAGES C)
3910

40-
include(../setup.cmake)
41-
include(platform)
11+
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
4212

43-
enable_pic()
13+
IF(DISABLE_THESE_LINES)
14+
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
15+
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
16+
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
17+
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
18+
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
19+
ENDIF(DISABLE_THESE_LINES)
4420

4521
include(CheckTypeSize)
4622
include(CheckFunctionExists)
4723
include(CheckIncludeFile)
4824
include(CheckCSourceCompiles)
25+
# enable_testing()
4926

5027
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
5128
check_include_file(stdint.h HAVE_STDINT_H)
@@ -86,13 +63,40 @@ endif()
8663
#
8764
check_include_file(unistd.h Z_HAVE_UNISTD_H)
8865

66+
IF(DISABLE_THESE_LINES)
67+
if(MSVC)
68+
set(CMAKE_DEBUG_POSTFIX "d")
69+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
70+
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
71+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
72+
endif()
73+
74+
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
75+
# If we're doing an out of source build and the user has a zconf.h
76+
# in their source tree...
77+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
78+
message(STATUS "Renaming")
79+
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
80+
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
81+
message(STATUS "but CMake generates it automatically in the build directory.")
82+
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
83+
endif()
84+
endif()
85+
86+
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
87+
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
88+
${ZLIB_PC} @ONLY)
89+
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
90+
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
91+
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
92+
ENDIF(DISABLE_THESE_LINES)
8993

90-
configure_file(
94+
CONFIGURE_FILE(
9195
${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
9296
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY
9397
)
94-
include_directories(
95-
SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
98+
INCLUDE_DIRECTORIES(
99+
BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
96100
)
97101

98102

@@ -144,33 +148,9 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
144148
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
145149
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
146150

147-
# -------------------------------------------------------------------------
148-
# Disable compile warnings
149-
150-
if(MSVC)
151-
152-
add_compile_options(
153-
/wd4996
154-
/wd4267
155-
/wd4131 # old style declarator
156-
/wd4127 # conditional expression is constant
157-
/wd4244 # possible loss of data during conversion
158-
/wd4245 # signed/unsigned missmatch
159-
)
151+
add_compile_options(-fPIC)
160152

161-
endif()
162-
163-
if (APPLE)
164-
# Disable warning for zlib 1.2.13.
165-
# In zlib version 1.3 this problem should be fixed:
166-
# https://github.com/madler/zlib/issues/633
167-
add_compile_options(-Wno-deprecated-non-prototype)
168-
endif()
169-
170-
# -------------------------------------------------------------------------
171-
172-
ADD_LIBRARY(zlib STATIC
173-
${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
153+
add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
174154

175155
target_include_directories(zlib PUBLIC
176156
${PROJECT_BINARY_DIR}
@@ -179,6 +159,36 @@ target_include_directories(zlib PUBLIC
179159

180160
set_target_properties(zlib PROPERTIES FOLDER "Misc")
181161

162+
export(TARGETS zlib NAMESPACE ext_ FILE ${PROJECT_BINARY_DIR}/exports.cmake)
163+
164+
RETURN()
165+
166+
# Skip anything below.
167+
################################################################
168+
169+
if(MINGW)
170+
# This gets us DLL resource information when compiling on MinGW.
171+
if(NOT CMAKE_RC_COMPILER)
172+
set(CMAKE_RC_COMPILER windres.exe)
173+
endif()
174+
175+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
176+
COMMAND ${CMAKE_RC_COMPILER}
177+
-D GCC_WINDRES
178+
-I ${CMAKE_CURRENT_SOURCE_DIR}
179+
-I ${CMAKE_CURRENT_BINARY_DIR}
180+
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
181+
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
182+
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
183+
endif(MINGW)
184+
185+
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
186+
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
187+
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
188+
target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
189+
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
190+
set_target_properties(zlib PROPERTIES SOVERSION 1)
191+
182192
if(NOT CYGWIN)
183193
# This property causes shared libraries on Linux to have the full version
184194
# encoded into their final filename. We disable this on Cygwin because
@@ -190,18 +200,52 @@ if(NOT CYGWIN)
190200
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
191201
endif()
192202

193-
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
203+
if(UNIX)
194204
# On unix-like platforms the library is almost always called libz
195-
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
196-
elseif(UNIX)
197-
# On unix-like platforms the library is almost always called libz
198-
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
199-
if(NOT APPLE)
205+
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
206+
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
200207
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
201208
endif()
209+
elseif(BUILD_SHARED_LIBS AND WIN32)
210+
# Creates zlib1.dll when building shared library version
211+
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
202212
endif()
203213

204-
#ADD_EXECUTABLE(try_zlib try.cc)
205-
#TARGET_LINK_LIBRARIES(try_zlib zlib)
214+
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
215+
install(TARGETS zlib zlibstatic
216+
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
217+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
218+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
219+
endif()
220+
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
221+
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
222+
endif()
223+
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
224+
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
225+
endif()
226+
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
227+
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
228+
endif()
206229

207-
export(TARGETS zlib NAMESPACE ext_ FILE ${PROJECT_BINARY_DIR}/exports.cmake)
230+
#============================================================================
231+
# Example binaries
232+
#============================================================================
233+
if(ZLIB_BUILD_EXAMPLES)
234+
add_executable(example test/example.c)
235+
target_link_libraries(example zlib)
236+
add_test(example example)
237+
238+
add_executable(minigzip test/minigzip.c)
239+
target_link_libraries(minigzip zlib)
240+
241+
if(HAVE_OFF64_T)
242+
add_executable(example64 test/example.c)
243+
target_link_libraries(example64 zlib)
244+
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
245+
add_test(example64 example64)
246+
247+
add_executable(minigzip64 test/minigzip.c)
248+
target_link_libraries(minigzip64 zlib)
249+
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
250+
endif()
251+
endif()

cdk/extra/zlib/ChangeLog

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11

22
ChangeLog file for zlib
33

4+
Changes in 1.3.1 (22 Jan 2024)
5+
- Reject overflows of zip header fields in minizip
6+
- Fix bug in inflateSync() for data held in bit buffer
7+
- Add LIT_MEM define to use more memory for a small deflate speedup
8+
- Fix decision on the emission of Zip64 end records in minizip
9+
- Add bounds checking to ERR_MSG() macro, used by zError()
10+
- Neutralize zip file traversal attacks in miniunz
11+
- Fix a bug in ZLIB_DEBUG compiles in check_match()
12+
- Various portability and appearance improvements
13+
14+
Changes in 1.3 (18 Aug 2023)
15+
- Remove K&R function definitions and zlib2ansi
16+
- Fix bug in deflateBound() for level 0 and memLevel 9
17+
- Fix bug when gzungetc() is used immediately after gzopen()
18+
- Fix bug when using gzflush() with a very small buffer
19+
- Fix crash when gzsetparams() attempted for transparent write
20+
- Fix test/example.c to work with FORCE_STORED
21+
- Rewrite of zran in examples (see zran.c version history)
22+
- Fix minizip to allow it to open an empty zip file
23+
- Fix reading disk number start on zip64 files in minizip
24+
- Fix logic error in minizip argument processing
25+
- Add minizip testing to Makefile
26+
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
27+
- Add memory sanitizer to configure (--memory)
28+
- Various portability improvements
29+
- Various documentation improvements
30+
- Various spelling and typo corrections
31+
432
Changes in 1.2.13 (13 Oct 2022)
533
- Fix configure issue that discarded provided CC definition
634
- Correct incorrect inputs provided to the CRC functions
@@ -1445,7 +1473,7 @@ Changes in 0.99 (27 Jan 96)
14451473
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
14461474
- in fcalloc, normalize pointer if size > 65520 bytes
14471475
- don't use special fcalloc for 32 bit Borland C++
1448-
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
1476+
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
14491477
- use Z_BINARY instead of BINARY
14501478
- document that gzclose after gzdopen will close the file
14511479
- allow "a" as mode in gzopen

cdk/extra/zlib/FAQ

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
If your question is not there, please check the zlib home page
66
http://zlib.net/ which may have more recent information.
7-
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
7+
The latest zlib FAQ is at http://zlib.net/zlib_faq.html
88

99

1010
1. Is zlib Y2K-compliant?
@@ -14,8 +14,7 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
1414
2. Where can I get a Windows DLL version?
1515

1616
The zlib sources can be compiled without change to produce a DLL. See the
17-
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
18-
precompiled DLL are found in the zlib web site at http://zlib.net/ .
17+
file win32/DLL_FAQ.txt in the zlib distribution.
1918

2019
3. Where can I get a Visual Basic interface to zlib?
2120

cdk/extra/zlib/Makefile.in

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for zlib
2-
# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler
2+
# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
33
# For conditions of distribution and use, see copyright notice in zlib.h
44

55
# To compile and test, type:
@@ -22,13 +22,13 @@ CFLAGS=-O
2222

2323
SFLAGS=-O
2424
LDFLAGS=
25-
TEST_LDFLAGS=$(LDFLAGS) -L. libz.a
25+
TEST_LIBS=-L. libz.a
2626
LDSHARED=$(CC)
2727
CPP=$(CC) -E
2828

2929
STATICLIB=libz.a
3030
SHAREDLIB=libz.so
31-
SHAREDLIBV=libz.so.1.2.13
31+
SHAREDLIBV=libz.so.1.3.1
3232
SHAREDLIBM=libz.so.1
3333
LIBS=$(STATICLIB) $(SHAREDLIBV)
3434

@@ -282,10 +282,10 @@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
282282
-@rmdir objs
283283

284284
example$(EXE): example.o $(STATICLIB)
285-
$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
285+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS)
286286

287287
minigzip$(EXE): minigzip.o $(STATICLIB)
288-
$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
288+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS)
289289

290290
examplesh$(EXE): example.o $(SHAREDLIBV)
291291
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV)
@@ -294,10 +294,10 @@ minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
294294
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV)
295295

296296
example64$(EXE): example64.o $(STATICLIB)
297-
$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
297+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS)
298298

299299
minigzip64$(EXE): minigzip64.o $(STATICLIB)
300-
$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
300+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS)
301301

302302
install-libs: $(LIBS)
303303
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
@@ -359,8 +359,14 @@ zconf.h.cmakein: $(SRCDIR)zconf.h.in
359359
zconf: $(SRCDIR)zconf.h.in
360360
cp -p $(SRCDIR)zconf.h.in zconf.h
361361

362+
minizip-test: static
363+
cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
364+
365+
minizip-clean:
366+
cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; }
367+
362368
mostlyclean: clean
363-
clean:
369+
clean: minizip-clean
364370
rm -f *.o *.lo *~ \
365371
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
366372
example64$(EXE) minigzip64$(EXE) \

0 commit comments

Comments
 (0)