Skip to content

Commit 6a1cc8b

Browse files
authored
bpo-45743: Remove workaround for zlib CVE from 2002 (GH-29457)
1 parent 8fefaad commit 6a1cc8b

File tree

1 file changed

+11
-40
lines changed

1 file changed

+11
-40
lines changed

Diff for: setup.py

+11-40
Original file line numberDiff line numberDiff line change
@@ -1633,56 +1633,27 @@ def detect_platform_specific_exts(self):
16331633
'-framework', 'CoreFoundation']))
16341634

16351635
def detect_compress_exts(self):
1636-
# Andrew Kuchling's zlib module. Note that some versions of zlib
1637-
# 1.1.3 have security problems. See CERT Advisory CA-2002-07:
1638-
# http://www.cert.org/advisories/CA-2002-07.html
1639-
#
1640-
# zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to
1641-
# patch its zlib 1.1.3 package instead of upgrading to 1.1.4. For
1642-
# now, we still accept 1.1.3, because we think it's difficult to
1643-
# exploit this in Python, and we'd rather make it RedHat's problem
1644-
# than our problem <wink>.
1645-
#
1646-
# You can upgrade zlib to version 1.1.4 yourself by going to
1647-
# http://www.gzip.org/zlib/
1648-
zlib_inc = find_file('zlib.h', [], self.inc_dirs)
1649-
have_zlib = False
1650-
if zlib_inc is not None:
1651-
zlib_h = zlib_inc[0] + '/zlib.h'
1652-
version = '"0.0.0"'
1653-
version_req = '"1.1.3"'
1654-
if MACOS and is_macosx_sdk_path(zlib_h):
1655-
zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
1656-
with open(zlib_h) as fp:
1657-
while 1:
1658-
line = fp.readline()
1659-
if not line:
1660-
break
1661-
if line.startswith('#define ZLIB_VERSION'):
1662-
version = line.split()[2]
1663-
break
1664-
if version >= version_req:
1665-
if (self.compiler.find_library_file(self.lib_dirs, 'z')):
1666-
self.add(Extension('zlib', ['zlibmodule.c'],
1667-
libraries=['z']))
1668-
have_zlib = True
1669-
else:
1670-
self.missing.append('zlib')
1671-
else:
1672-
self.missing.append('zlib')
1636+
# Andrew Kuchling's zlib module.
1637+
have_zlib = (
1638+
find_file('zlib.h', self.inc_dirs, []) is not None and
1639+
self.compiler.find_library_file(self.lib_dirs, 'z')
1640+
)
1641+
if have_zlib:
1642+
self.add(Extension('zlib', ['zlibmodule.c'],
1643+
libraries=['z']))
16731644
else:
16741645
self.missing.append('zlib')
16751646

16761647
# Helper module for various ascii-encoders. Uses zlib for an optimized
16771648
# crc32 if we have it. Otherwise binascii uses its own.
1678-
extra_compile_args = []
16791649
if have_zlib:
1680-
extra_compile_args.append('-DUSE_ZLIB_CRC32')
1650+
define_macros = [('USE_ZLIB_CRC32', None)]
16811651
libraries = ['z']
16821652
else:
1653+
define_macros = None
16831654
libraries = []
16841655
self.add(Extension('binascii', ['binascii.c'],
1685-
extra_compile_args=extra_compile_args,
1656+
define_macros=define_macros,
16861657
libraries=libraries))
16871658

16881659
# Gustavo Niemeyer's bz2 module.

0 commit comments

Comments
 (0)