Skip to content

Commit bc12565

Browse files
author
Flatcar Buildbot
committed
sys-libs/zlib: Sync with Gentoo
It's from Gentoo commit 8999beb783251a357175e47e74aa2417f2b6ff5f.
1 parent 32d69f3 commit bc12565

File tree

5 files changed

+405
-2
lines changed

5 files changed

+405
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
https://bugs.gentoo.org/916484
2+
https://github.com/madler/zlib/pull/843
3+
https://github.com/madler/zlib/commit/73331a6a0481067628f065ffe87bb1d8f787d10c
4+
5+
From 73331a6a0481067628f065ffe87bb1d8f787d10c Mon Sep 17 00:00:00 2001
6+
From: Hans Wennborg <hans@chromium.org>
7+
Date: Fri, 18 Aug 2023 11:05:33 +0200
8+
Subject: [PATCH] Reject overflows of zip header fields in minizip.
9+
10+
This checks the lengths of the file name, extra field, and comment
11+
that would be put in the zip headers, and rejects them if they are
12+
too long. They are each limited to 65535 bytes in length by the zip
13+
format. This also avoids possible buffer overflows if the provided
14+
fields are too long.
15+
---
16+
contrib/minizip/zip.c | 11 +++++++++++
17+
1 file changed, 11 insertions(+)
18+
19+
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
20+
index 3d3d4cadd..0446109b2 100644
21+
--- a/contrib/minizip/zip.c
22+
+++ b/contrib/minizip/zip.c
23+
@@ -1043,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
24+
return ZIP_PARAMERROR;
25+
#endif
26+
27+
+ // The filename and comment length must fit in 16 bits.
28+
+ if ((filename!=NULL) && (strlen(filename)>0xffff))
29+
+ return ZIP_PARAMERROR;
30+
+ if ((comment!=NULL) && (strlen(comment)>0xffff))
31+
+ return ZIP_PARAMERROR;
32+
+ // The extra field length must fit in 16 bits. If the member also requires
33+
+ // a Zip64 extra block, that will also need to fit within that 16-bit
34+
+ // length, but that will be checked for later.
35+
+ if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
36+
+ return ZIP_PARAMERROR;
37+
+
38+
zi = (zip64_internal*)file;
39+
40+
if (zi->in_opened_file_inzip == 1)

sdk_container/src/third_party/portage-stable/sys-libs/zlib/zlib-1.2.13-r1.ebuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ EAPI=8
55

66
# Worth keeping an eye on 'develop' branch upstream for possible backports.
77
AUTOTOOLS_AUTO_DEPEND="no"
8-
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/madler.asc
8+
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/madler.asc
99
inherit autotools multilib-minimal flag-o-matic toolchain-funcs usr-ldscript verify-sig
1010

1111
DESCRIPTION="Standard (de)compression library"
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Copyright 1999-2023 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
# Worth keeping an eye on 'develop' branch upstream for possible backports.
7+
AUTOTOOLS_AUTO_DEPEND="no"
8+
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/madler.asc
9+
inherit autotools multilib-minimal flag-o-matic toolchain-funcs usr-ldscript verify-sig
10+
11+
DESCRIPTION="Standard (de)compression library"
12+
HOMEPAGE="https://zlib.net/"
13+
SRC_URI="https://zlib.net/${P}.tar.xz
14+
https://zlib.net/fossils/${P}.tar.xz
15+
https://zlib.net/current/beta/${P}.tar.xz
16+
verify-sig? ( https://zlib.net/${P}.tar.xz.asc )"
17+
18+
LICENSE="ZLIB"
19+
SLOT="0/1" # subslot = SONAME
20+
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
21+
IUSE="minizip static-libs"
22+
23+
RDEPEND="!sys-libs/zlib-ng[compat]"
24+
DEPEND="${RDEPEND}"
25+
BDEPEND="
26+
minizip? ( ${AUTOTOOLS_DEPEND} )
27+
verify-sig? ( sec-keys/openpgp-keys-madler )
28+
"
29+
30+
PATCHES=(
31+
# Don't install unexpected & unused crypt.h header (which would clash with other pkgs)
32+
# Pending upstream. bug #658536
33+
"${FILESDIR}"/${PN}-1.2.11-minizip-drop-crypt-header.patch
34+
35+
# Respect AR, RANLIB, NM during build. Pending upstream. bug #831628
36+
"${FILESDIR}"/${PN}-1.2.11-configure-fix-AR-RANLIB-NM-detection.patch
37+
38+
# Respect LDFLAGS during configure tests. Pending upstream
39+
"${FILESDIR}"/${PN}-1.2.13-use-LDFLAGS-in-configure.patch
40+
41+
# Fix building on sparc with older binutils, we pass it in ebuild instead
42+
"${FILESDIR}"/${PN}-1.2.13-Revert-Turn-off-RWX-segment-warnings-on-sparc-system.patch
43+
44+
# CVE-2023-45853 (bug #916484)
45+
"${FILESDIR}"/${PN}-1.2.13-CVE-2023-45853.patch
46+
)
47+
48+
src_prepare() {
49+
default
50+
51+
if use minizip ; then
52+
cd contrib/minizip || die
53+
eautoreconf
54+
fi
55+
56+
case ${CHOST} in
57+
*-mingw*|mingw*)
58+
# Uses preconfigured Makefile rather than configure script
59+
multilib_copy_sources
60+
61+
;;
62+
esac
63+
}
64+
65+
echoit() { echo "$@"; "$@"; }
66+
67+
multilib_src_configure() {
68+
# We pass manually instead of relying on the configure script/makefile
69+
# because it would pass it even for older binutils.
70+
use sparc && append-flags $(test-flags-CCLD -Wl,--no-warn-rwx-segments)
71+
72+
# ideally we want !tc-ld-is-bfd for best future-proofing, but it needs
73+
# https://github.com/gentoo/gentoo/pull/28355
74+
# mold needs this too but right now tc-ld-is-mold is also not available
75+
if tc-ld-is-lld; then
76+
append-ldflags -Wl,--undefined-version
77+
fi
78+
79+
case ${CHOST} in
80+
*-mingw*|mingw*)
81+
;;
82+
83+
*)
84+
# bug #347167
85+
local uname=$("${BROOT}"/usr/share/gnuconfig/config.sub "${CHOST}" | cut -d- -f3)
86+
87+
local myconf=(
88+
--shared
89+
--prefix="${EPREFIX}/usr"
90+
--libdir="${EPREFIX}/usr/$(get_libdir)"
91+
${uname:+--uname=${uname}}
92+
)
93+
94+
# Not an autoconf script, so can't use econf
95+
echoit "${S}"/configure "${myconf[@]}" || die
96+
97+
;;
98+
esac
99+
100+
if use minizip ; then
101+
local minizipdir="contrib/minizip"
102+
mkdir -p "${BUILD_DIR}/${minizipdir}" || die
103+
104+
cd ${minizipdir} || die
105+
ECONF_SOURCE="${S}/${minizipdir}" econf $(use_enable static-libs static)
106+
fi
107+
}
108+
109+
multilib_src_compile() {
110+
case ${CHOST} in
111+
*-mingw*|mingw*)
112+
emake -f win32/Makefile.gcc STRIP=true PREFIX=${CHOST}-
113+
sed \
114+
-e 's|@prefix@|'"${EPREFIX}"'/usr|g' \
115+
-e 's|@exec_prefix@|${prefix}|g' \
116+
-e 's|@libdir@|${exec_prefix}/'$(get_libdir)'|g' \
117+
-e 's|@sharedlibdir@|${exec_prefix}/'$(get_libdir)'|g' \
118+
-e 's|@includedir@|${prefix}/include|g' \
119+
-e 's|@VERSION@|'${PV}'|g' \
120+
zlib.pc.in > zlib.pc || die
121+
;;
122+
123+
*)
124+
emake
125+
126+
;;
127+
esac
128+
129+
use minizip && emake -C contrib/minizip
130+
}
131+
132+
sed_macros() {
133+
# Clean up namespace a little, bug #383179
134+
# We do it here so we only have to tweak 2 files
135+
sed -i -r 's:\<(O[FN])\>:_Z_\1:g' "$@" || die
136+
}
137+
138+
multilib_src_install() {
139+
case ${CHOST} in
140+
*-mingw*|mingw*)
141+
emake -f win32/Makefile.gcc install \
142+
BINARY_PATH="${ED}/usr/bin" \
143+
LIBRARY_PATH="${ED}/usr/$(get_libdir)" \
144+
INCLUDE_PATH="${ED}/usr/include" \
145+
SHARED_MODE=1
146+
147+
# Overwrites zlib.pc created from win32/Makefile.gcc, bug #620136
148+
insinto /usr/$(get_libdir)/pkgconfig
149+
doins zlib.pc
150+
151+
;;
152+
153+
*)
154+
emake install DESTDIR="${D}" LDCONFIG=:
155+
gen_usr_ldscript -a z
156+
157+
;;
158+
esac
159+
160+
sed_macros "${ED}"/usr/include/*.h
161+
162+
if use minizip ; then
163+
emake -C contrib/minizip install DESTDIR="${D}"
164+
sed_macros "${ED}"/usr/include/minizip/*.h
165+
166+
# This might not exist if slibtool is used.
167+
# bug #816756
168+
rm -f "${ED}"/usr/$(get_libdir)/libminizip.la || die
169+
fi
170+
171+
if ! use static-libs ; then
172+
# bug #419645
173+
rm "${ED}"/usr/$(get_libdir)/libz.a || die
174+
fi
175+
}
176+
177+
multilib_src_install_all() {
178+
dodoc FAQ README ChangeLog doc/*.txt
179+
180+
if use minizip ; then
181+
dodoc contrib/minizip/*.txt
182+
doman contrib/minizip/*.1
183+
fi
184+
}

sdk_container/src/third_party/portage-stable/sys-libs/zlib/zlib-1.3-r1.ebuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ EAPI=8
55

66
# Worth keeping an eye on 'develop' branch upstream for possible backports.
77
AUTOTOOLS_AUTO_DEPEND="no"
8-
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/madler.asc
8+
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/madler.asc
99
inherit autotools edo multilib-minimal flag-o-matic toolchain-funcs usr-ldscript verify-sig
1010

1111
DESCRIPTION="Standard (de)compression library"

0 commit comments

Comments
 (0)