1 |
commit: 156d2bd5e79f0d331afc1ff82b565350fe5ea93c |
2 |
Author: Stephan Hartmann <stha09 <AT> googlemail <DOT> com> |
3 |
AuthorDate: Wed Feb 26 11:15:01 2020 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 26 11:49:08 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=156d2bd5 |
7 |
|
8 |
dev-libs/icu: add patch to fix integer overflow |
9 |
|
10 |
Bug: https://bugs.gentoo.org/710758 |
11 |
Package-Manager: Portage-2.3.84, Repoman-2.3.20 |
12 |
Signed-off-by: Stephan Hartmann <stha09 <AT> googlemail.com> |
13 |
Closes: https://github.com/gentoo/gentoo/pull/14779 |
14 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
15 |
|
16 |
dev-libs/icu/files/icu-65.1-integer-overflow.patch | 118 +++++++++++++++++ |
17 |
dev-libs/icu/icu-65.1-r1.ebuild | 143 +++++++++++++++++++++ |
18 |
2 files changed, 261 insertions(+) |
19 |
|
20 |
diff --git a/dev-libs/icu/files/icu-65.1-integer-overflow.patch b/dev-libs/icu/files/icu-65.1-integer-overflow.patch |
21 |
new file mode 100644 |
22 |
index 00000000000..8e76a9f289d |
23 |
--- /dev/null |
24 |
+++ b/dev-libs/icu/files/icu-65.1-integer-overflow.patch |
25 |
@@ -0,0 +1,118 @@ |
26 |
+From b7d08bc04a4296982fcef8b6b8a354a9e4e7afca Mon Sep 17 00:00:00 2001 |
27 |
+From: Frank Tang <ftang@××××××××.org> |
28 |
+Date: Sat, 1 Feb 2020 02:39:04 +0000 |
29 |
+Subject: [PATCH] ICU-20958 Prevent SEGV_MAPERR in append |
30 |
+ |
31 |
+See #971 |
32 |
+--- |
33 |
+ common/unistr.cpp | 6 ++- |
34 |
+ test/intltest/ustrtest.cpp | 62 +++++++++++++++++++++++++ |
35 |
+ test/intltest/ustrtest.h | 1 + |
36 |
+ 3 files changed, 68 insertions(+), 1 deletion(-) |
37 |
+ |
38 |
+diff --git a/common/unistr.cpp b/common/unistr.cpp |
39 |
+index 901bb3358ba..077b4d6ef20 100644 |
40 |
+--- a/common/unistr.cpp |
41 |
++++ b/common/unistr.cpp |
42 |
+@@ -1563,7 +1563,11 @@ UnicodeString::doAppend(const UChar *srcChars, int32_t srcStart, int32_t srcLeng |
43 |
+ } |
44 |
+ |
45 |
+ int32_t oldLength = length(); |
46 |
+- int32_t newLength = oldLength + srcLength; |
47 |
++ int32_t newLength; |
48 |
++ if (uprv_add32_overflow(oldLength, srcLength, &newLength)) { |
49 |
++ setToBogus(); |
50 |
++ return *this; |
51 |
++ } |
52 |
+ |
53 |
+ // Check for append onto ourself |
54 |
+ const UChar* oldArray = getArrayStart(); |
55 |
+diff --git a/test/intltest/ustrtest.cpp b/test/intltest/ustrtest.cpp |
56 |
+index b6515ea813c..ad38bdf53a3 100644 |
57 |
+--- a/test/intltest/ustrtest.cpp |
58 |
++++ b/test/intltest/ustrtest.cpp |
59 |
+@@ -67,6 +67,7 @@ void UnicodeStringTest::runIndexedTest( int32_t index, UBool exec, const char* & |
60 |
+ TESTCASE_AUTO(TestWCharPointers); |
61 |
+ TESTCASE_AUTO(TestNullPointers); |
62 |
+ TESTCASE_AUTO(TestUnicodeStringInsertAppendToSelf); |
63 |
++ TESTCASE_AUTO(TestLargeAppend); |
64 |
+ TESTCASE_AUTO_END; |
65 |
+ } |
66 |
+ |
67 |
+@@ -2310,3 +2311,64 @@ void UnicodeStringTest::TestUnicodeStringInsertAppendToSelf() { |
68 |
+ str.insert(2, sub); |
69 |
+ assertEquals("", u"abbcdcde", str); |
70 |
+ } |
71 |
++ |
72 |
++void UnicodeStringTest::TestLargeAppend() { |
73 |
++ if(quick) return; |
74 |
++ |
75 |
++ IcuTestErrorCode status(*this, "TestLargeAppend"); |
76 |
++ // Make a large UnicodeString |
77 |
++ int32_t len = 0xAFFFFFF; |
78 |
++ UnicodeString str; |
79 |
++ char16_t *buf = str.getBuffer(len); |
80 |
++ // A fast way to set buffer to valid Unicode. |
81 |
++ // 4E4E is a valid unicode character |
82 |
++ uprv_memset(buf, 0x4e, len * 2); |
83 |
++ str.releaseBuffer(len); |
84 |
++ UnicodeString dest; |
85 |
++ // Append it 16 times |
86 |
++ // 0xAFFFFFF times 16 is 0xA4FFFFF1, |
87 |
++ // which is greater than INT32_MAX, which is 0x7FFFFFFF. |
88 |
++ int64_t total = 0; |
89 |
++ for (int32_t i = 0; i < 16; i++) { |
90 |
++ dest.append(str); |
91 |
++ total += len; |
92 |
++ if (total <= INT32_MAX) { |
93 |
++ assertFalse("dest is not bogus", dest.isBogus()); |
94 |
++ } else { |
95 |
++ assertTrue("dest should be bogus", dest.isBogus()); |
96 |
++ } |
97 |
++ } |
98 |
++ dest.remove(); |
99 |
++ total = 0; |
100 |
++ for (int32_t i = 0; i < 16; i++) { |
101 |
++ dest.append(str); |
102 |
++ total += len; |
103 |
++ if (total + len <= INT32_MAX) { |
104 |
++ assertFalse("dest is not bogus", dest.isBogus()); |
105 |
++ } else if (total <= INT32_MAX) { |
106 |
++ // Check that a string of exactly the maximum size works |
107 |
++ UnicodeString str2; |
108 |
++ int32_t remain = INT32_MAX - total; |
109 |
++ char16_t *buf2 = str2.getBuffer(remain); |
110 |
++ if (buf2 == nullptr) { |
111 |
++ // if somehow memory allocation fail, return the test |
112 |
++ return; |
113 |
++ } |
114 |
++ uprv_memset(buf2, 0x4e, remain * 2); |
115 |
++ str2.releaseBuffer(remain); |
116 |
++ dest.append(str2); |
117 |
++ total += remain; |
118 |
++ assertEquals("When a string of exactly the maximum size works", (int64_t)INT32_MAX, total); |
119 |
++ assertEquals("When a string of exactly the maximum size works", INT32_MAX, dest.length()); |
120 |
++ assertFalse("dest is not bogus", dest.isBogus()); |
121 |
++ |
122 |
++ // Check that a string size+1 goes bogus |
123 |
++ str2.truncate(1); |
124 |
++ dest.append(str2); |
125 |
++ total++; |
126 |
++ assertTrue("dest should be bogus", dest.isBogus()); |
127 |
++ } else { |
128 |
++ assertTrue("dest should be bogus", dest.isBogus()); |
129 |
++ } |
130 |
++ } |
131 |
++} |
132 |
+diff --git a/test/intltest/ustrtest.h b/test/intltest/ustrtest.h |
133 |
+index 218befdcc68..4a356a92c7a 100644 |
134 |
+--- a/test/intltest/ustrtest.h |
135 |
++++ b/test/intltest/ustrtest.h |
136 |
+@@ -97,6 +97,7 @@ class UnicodeStringTest: public IntlTest { |
137 |
+ void TestWCharPointers(); |
138 |
+ void TestNullPointers(); |
139 |
+ void TestUnicodeStringInsertAppendToSelf(); |
140 |
++ void TestLargeAppend(); |
141 |
+ }; |
142 |
+ |
143 |
+ #endif |
144 |
|
145 |
diff --git a/dev-libs/icu/icu-65.1-r1.ebuild b/dev-libs/icu/icu-65.1-r1.ebuild |
146 |
new file mode 100644 |
147 |
index 00000000000..d8ae0db9cdb |
148 |
--- /dev/null |
149 |
+++ b/dev-libs/icu/icu-65.1-r1.ebuild |
150 |
@@ -0,0 +1,143 @@ |
151 |
+# Copyright 1999-2020 Gentoo Authors |
152 |
+# Distributed under the terms of the GNU General Public License v2 |
153 |
+ |
154 |
+EAPI=7 |
155 |
+ |
156 |
+PYTHON_COMPAT=( python3_{6,7} ) |
157 |
+inherit autotools flag-o-matic multilib-minimal python-any-r1 toolchain-funcs |
158 |
+ |
159 |
+DESCRIPTION="International Components for Unicode" |
160 |
+HOMEPAGE="http://www.icu-project.org/" |
161 |
+SRC_URI="https://github.com/unicode-org/icu/releases/download/release-${PV//./-}/icu4c-${PV//./_}-src.tgz" |
162 |
+ |
163 |
+LICENSE="BSD" |
164 |
+ |
165 |
+SLOT="0/${PV}" |
166 |
+ |
167 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt" |
168 |
+IUSE="debug doc examples static-libs" |
169 |
+ |
170 |
+BDEPEND="${PYTHON_DEPS} |
171 |
+ virtual/pkgconfig |
172 |
+ doc? ( app-doc/doxygen[dot] ) |
173 |
+" |
174 |
+ |
175 |
+S="${WORKDIR}/${PN}/source" |
176 |
+ |
177 |
+MULTILIB_CHOST_TOOLS=( |
178 |
+ /usr/bin/icu-config |
179 |
+) |
180 |
+ |
181 |
+PATCHES=( |
182 |
+ "${FILESDIR}/${PN}-65.1-remove-bashisms.patch" |
183 |
+ "${FILESDIR}/${PN}-64.2-darwin.patch" |
184 |
+ "${FILESDIR}/${PN}-64.1-data_archive_generation.patch" |
185 |
+ "${FILESDIR}/${PN}-65.1-integer-overflow.patch" # bug 710758 |
186 |
+) |
187 |
+ |
188 |
+src_prepare() { |
189 |
+ default |
190 |
+ |
191 |
+ local variable |
192 |
+ |
193 |
+ # Disable renaming as it is stupid thing to do |
194 |
+ sed -i \ |
195 |
+ -e "s/#define U_DISABLE_RENAMING 0/#define U_DISABLE_RENAMING 1/" \ |
196 |
+ common/unicode/uconfig.h || die |
197 |
+ |
198 |
+ # Fix linking of icudata |
199 |
+ sed -i \ |
200 |
+ -e "s:LDFLAGSICUDT=-nodefaultlibs -nostdlib:LDFLAGSICUDT=:" \ |
201 |
+ config/mh-linux || die |
202 |
+ |
203 |
+ # Append doxygen configuration to configure |
204 |
+ sed -i \ |
205 |
+ -e 's:icudefs.mk:icudefs.mk Doxyfile:' \ |
206 |
+ configure.ac || die |
207 |
+ |
208 |
+ eautoreconf |
209 |
+} |
210 |
+ |
211 |
+src_configure() { |
212 |
+ append-cxxflags -std=c++14 |
213 |
+ |
214 |
+ if tc-is-cross-compiler; then |
215 |
+ mkdir "${WORKDIR}"/host || die |
216 |
+ pushd "${WORKDIR}"/host >/dev/null || die |
217 |
+ |
218 |
+ CFLAGS="" CXXFLAGS="" ASFLAGS="" LDFLAGS="" \ |
219 |
+ CC="$(tc-getBUILD_CC)" CXX="$(tc-getBUILD_CXX)" AR="$(tc-getBUILD_AR)" \ |
220 |
+ RANLIB="$(tc-getBUILD_RANLIB)" LD="$(tc-getBUILD_LD)" \ |
221 |
+ "${S}"/configure --disable-renaming --disable-debug \ |
222 |
+ --disable-samples --enable-static || die |
223 |
+ emake |
224 |
+ |
225 |
+ popd >/dev/null || die |
226 |
+ fi |
227 |
+ |
228 |
+ multilib-minimal_src_configure |
229 |
+} |
230 |
+ |
231 |
+multilib_src_configure() { |
232 |
+ local myeconfargs=( |
233 |
+ --disable-renaming |
234 |
+ --disable-samples |
235 |
+ --disable-layoutex |
236 |
+ $(use_enable debug) |
237 |
+ $(use_enable static-libs static) |
238 |
+ $(multilib_native_use_enable examples samples) |
239 |
+ ) |
240 |
+ |
241 |
+ tc-is-cross-compiler && myeconfargs+=( |
242 |
+ --with-cross-build="${WORKDIR}"/host |
243 |
+ ) |
244 |
+ |
245 |
+ # icu tries to use clang by default |
246 |
+ tc-export CC CXX |
247 |
+ |
248 |
+ # make sure we configure with the same shell as we run icu-config |
249 |
+ # with, or ECHO_N, ECHO_T and ECHO_C will be wrongly defined |
250 |
+ export CONFIG_SHELL="${EPREFIX}/bin/sh" |
251 |
+ # probably have no /bin/sh in prefix-chain |
252 |
+ [[ -x ${CONFIG_SHELL} ]] || CONFIG_SHELL="${BASH}" |
253 |
+ |
254 |
+ ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
255 |
+} |
256 |
+ |
257 |
+multilib_src_compile() { |
258 |
+ default |
259 |
+ |
260 |
+ if multilib_is_native_abi && use doc; then |
261 |
+ doxygen -u Doxyfile || die |
262 |
+ doxygen Doxyfile || die |
263 |
+ fi |
264 |
+} |
265 |
+ |
266 |
+multilib_src_test() { |
267 |
+ # INTLTEST_OPTS: intltest options |
268 |
+ # -e: Exhaustive testing |
269 |
+ # -l: Reporting of memory leaks |
270 |
+ # -v: Increased verbosity |
271 |
+ # IOTEST_OPTS: iotest options |
272 |
+ # -e: Exhaustive testing |
273 |
+ # -v: Increased verbosity |
274 |
+ # CINTLTST_OPTS: cintltst options |
275 |
+ # -e: Exhaustive testing |
276 |
+ # -v: Increased verbosity |
277 |
+ emake -j1 VERBOSE="1" check |
278 |
+} |
279 |
+ |
280 |
+multilib_src_install() { |
281 |
+ default |
282 |
+ |
283 |
+ if multilib_is_native_abi && use doc; then |
284 |
+ docinto html |
285 |
+ dodoc -r doc/html/* |
286 |
+ fi |
287 |
+} |
288 |
+ |
289 |
+multilib_src_install_all() { |
290 |
+ einstalldocs |
291 |
+ docinto html |
292 |
+ dodoc ../readme.html |
293 |
+} |