Skip to content

Commit d36d1fe

Browse files
Aditya Aarnabray21
authored andcommitted
Bug#28350915 CHERRY-PICK FIX FOR BUG#26275510
BUNDLED ZLIB DOESN'T INCLUDE FIXES FOR SOME VULNERABILITIES Upgrading the zlib lib to 1.2.11 (cherry picked from commit cc2517243ba3a380932314cd9d37705535770f19)
1 parent c00044d commit d36d1fe

Some content is hidden

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

83 files changed

+13914
-3416
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -382,6 +382,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
382382

383383
# Add bundled or system zlib.
384384
MYSQL_CHECK_ZLIB_WITH_COMPRESS()
385+
IF(BUILD_BUNDLED_ZLIB)
386+
INCLUDE_DIRECTORIES(SYSTEM
387+
${CMAKE_CURRENT_SOURCE_DIR}/zlib
388+
${CMAKE_CURRENT_BINARY_DIR}/zlib
389+
)
390+
ENDIF()
385391
# Optionally add bundled yassl/taocrypt or system openssl.
386392
MYSQL_CHECK_SSL()
387393
# Add readline or libedit.

client/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,6 @@
1515

1616
INCLUDE_DIRECTORIES(
1717
${CMAKE_SOURCE_DIR}/include
18-
${ZLIB_INCLUDE_DIR}
1918
${SSL_INCLUDE_DIRS}
2019
${CMAKE_SOURCE_DIR}/libmysql
2120
${CMAKE_SOURCE_DIR}/regex

cmake/plugin.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -56,7 +56,7 @@ MACRO(MYSQL_ADD_PLUGIN)
5656
${CMAKE_SOURCE_DIR}/sql
5757
${CMAKE_SOURCE_DIR}/regex
5858
${SSL_INCLUDE_DIRS}
59-
${ZLIB_INCLUDE_DIR})
59+
)
6060

6161
LIST(GET ARG_DEFAULT_ARGS 0 plugin)
6262
SET(SOURCES ${ARG_DEFAULT_ARGS})

cmake/zlib.cmake

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -14,15 +14,11 @@
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

1616
MACRO (MYSQL_USE_BUNDLED_ZLIB)
17-
SET(ZLIB_LIBRARY zlib)
18-
SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/zlib)
17+
SET(BUILD_BUNDLED_ZLIB 1)
18+
SET(ZLIB_LIBRARY zlib CACHE INTERNAL "Bundled zlib library")
1919
SET(ZLIB_FOUND TRUE)
2020
SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib")
2121
ADD_SUBDIRECTORY(zlib)
22-
GET_TARGET_PROPERTY(src zlib SOURCES)
23-
FOREACH(file ${src})
24-
SET(ZLIB_SOURCES ${ZLIB_SOURCES} ${CMAKE_SOURCE_DIR}/zlib/${file})
25-
ENDFOREACH()
2622
ENDMACRO()
2723

2824
# MYSQL_CHECK_ZLIB_WITH_COMPRESS
@@ -37,15 +33,10 @@ ENDMACRO()
3733

3834
MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS)
3935

40-
IF(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR
41-
CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
42-
CMAKE_SYSTEM_NAME STREQUAL "Windows")
43-
# Use bundled zlib on some platforms by default (system one is too
44-
# old or not existent)
36+
# For NDBCLUSTER: Use bundled zlib by default
4537
IF (NOT WITH_ZLIB)
4638
SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform")
4739
ENDIF()
48-
ENDIF()
4940

5041
IF(WITH_ZLIB STREQUAL "bundled")
5142
MYSQL_USE_BUNDLED_ZLIB()

extra/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,6 @@
1515

1616
INCLUDE_DIRECTORIES(
1717
${CMAKE_SOURCE_DIR}/include
18-
${ZLIB_INCLUDE_DIR}
1918
# Following is for perror, in case NDB is compiled in.
2019
${CMAKE_SOURCE_DIR}/storage/ndb/include
2120
${CMAKE_BINARY_DIR}/storage/ndb/include

libmysql/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES(
2121
${CMAKE_SOURCE_DIR}/strings
2222
${SSL_INCLUDE_DIRS}
2323
${SSL_INTERNAL_INCLUDE_DIRS}
24-
${ZLIB_INCLUDE_DIR})
24+
)
2525
ADD_DEFINITIONS(${SSL_DEFINES})
2626

2727
SET(CLIENT_API_FUNCTIONS

libmysqld/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@ ${CMAKE_SOURCE_DIR}/libmysqld
2323
${CMAKE_SOURCE_DIR}/sql
2424
${CMAKE_BINARY_DIR}/sql
2525
${CMAKE_SOURCE_DIR}/regex
26-
${ZLIB_INCLUDE_DIR}
2726
${SSL_INCLUDE_DIRS}
2827
${SSL_INTERNAL_INCLUDE_DIRS}
2928
${CMAKE_SOURCE_DIR}/sql/backup

mysys/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16-
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
16+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
1717

1818
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c
1919
errors.c hash.c list.c md5.c mf_cache.c mf_dirname.c mf_fn_ext.c

sql/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@ INCLUDE_DIRECTORIES(
1717
${CMAKE_SOURCE_DIR}/include
1818
${CMAKE_SOURCE_DIR}/sql
1919
${CMAKE_SOURCE_DIR}/regex
20-
${ZLIB_INCLUDE_DIR}
2120
${SSL_INCLUDE_DIRS}
2221
${CMAKE_BINARY_DIR}/sql
2322
)

zlib/CMakeLists.txt

Lines changed: 138 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,148 @@
1-
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
2-
#
1+
2+
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
3+
#
34
# This program is free software; you can redistribute it and/or modify
4-
# it under the terms of the GNU General Public License as published by
5-
# the Free Software Foundation; version 2 of the License.
6-
#
5+
# it under the terms of the GNU General Public License, version 2.0,
6+
# as published by the Free Software Foundation.
7+
#
78
# This program is distributed in the hope that it will be useful,
89
# but WITHOUT ANY WARRANTY; without even the implied warranty of
910
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10-
# GNU General Public License for more details.
11-
#
11+
# GNU General Public License, version 2.0, for more details.
12+
#
1213
# You should have received a copy of the GNU General Public License
1314
# along with this program; if not, write to the Free Software
14-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+
17+
cmake_minimum_required(VERSION 2.4.4)
18+
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
19+
20+
project(zlib C)
21+
22+
set(VERSION "1.2.11")
23+
24+
include(CheckTypeSize)
25+
include(CheckFunctionExists)
26+
include(CheckIncludeFile)
27+
include(CheckCSourceCompiles)
28+
29+
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
30+
check_include_file(stdint.h HAVE_STDINT_H)
31+
check_include_file(stddef.h HAVE_STDDEF_H)
32+
33+
#
34+
# Check to see if we have large file support
35+
#
36+
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
37+
# We add these other definitions here because CheckTypeSize.cmake
38+
# in CMake 2.4.x does not automatically do so and we want
39+
# compatibility with CMake 2.4.x.
40+
if(HAVE_SYS_TYPES_H)
41+
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
42+
endif()
43+
if(HAVE_STDINT_H)
44+
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
45+
endif()
46+
if(HAVE_STDDEF_H)
47+
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
48+
endif()
49+
check_type_size(off64_t OFF64_T)
50+
if(HAVE_OFF64_T)
51+
add_definitions(-D_LARGEFILE64_SOURCE=1)
52+
endif()
53+
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
54+
55+
#
56+
# Check for fseeko
57+
#
58+
check_function_exists(fseeko HAVE_FSEEKO)
59+
if(NOT HAVE_FSEEKO)
60+
add_definitions(-DNO_FSEEKO)
61+
endif()
62+
63+
#
64+
# Check for unistd.h
65+
#
66+
check_include_file(unistd.h Z_HAVE_UNISTD_H)
1567

16-
INCLUDE_DIRECTORIES(
17-
${CMAKE_SOURCE_DIR}/include
18-
${CMAKE_SOURCE_DIR}/zlib
68+
69+
configure_file(
70+
${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
71+
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY
72+
)
73+
include_directories(
74+
SYSTEM ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
75+
)
76+
77+
#============================================================================
78+
# zlib
79+
#============================================================================
80+
81+
set(ZLIB_PUBLIC_HDRS
82+
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
83+
zlib.h
84+
)
85+
set(ZLIB_PRIVATE_HDRS
86+
crc32.h
87+
deflate.h
88+
gzguts.h
89+
inffast.h
90+
inffixed.h
91+
inflate.h
92+
inftrees.h
93+
trees.h
94+
zutil.h
1995
)
20-
SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h
21-
inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h
22-
zutil.c zutil.h)
23-
ADD_CONVENIENCE_LIBRARY(zlib ${ZLIB_SOURCES})
24-
RESTRICT_SYMBOL_EXPORTS(zlib)
96+
set(ZLIB_SRCS
97+
adler32.c
98+
compress.c
99+
crc32.c
100+
deflate.c
101+
gzclose.c
102+
gzlib.c
103+
gzread.c
104+
gzwrite.c
105+
inflate.c
106+
infback.c
107+
inftrees.c
108+
inffast.c
109+
trees.c
110+
uncompr.c
111+
zutil.c
112+
)
113+
114+
if(NOT MINGW)
115+
set(ZLIB_DLL_SRCS
116+
win32/zlib1.rc # If present will override custom build rule below.
117+
)
118+
endif()
119+
120+
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
121+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
122+
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
123+
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
124+
125+
ADD_CONVENIENCE_LIBRARY(zlib STATIC
126+
${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
25127

26-
IF(MSVC)
27-
INSTALL_DEBUG_TARGET(zlib DESTINATION ${INSTALL_LIBDIR}/debug)
28-
ENDIF()
128+
if(NOT CYGWIN)
129+
# This property causes shared libraries on Linux to have the full version
130+
# encoded into their final filename. We disable this on Cygwin because
131+
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
132+
# seems to be the default.
133+
#
134+
# This has no effect with MSVC, on that platform the version info for
135+
# the DLL comes from the resource file win32/zlib1.rc
136+
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
137+
endif()
29138

139+
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
140+
# On unix-like platforms the library is almost always called libz
141+
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
142+
elseif(UNIX)
143+
# On unix-like platforms the library is almost always called libz
144+
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
145+
if(NOT APPLE)
146+
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
147+
endif()
148+
endif()

0 commit comments

Comments
 (0)