From: "Clément Lassieur" <clement@lassieur.org>
To: 26462@debbugs.gnu.org
Subject: bug#26462: [PATCH] gnu: icu4c: Fix crashes in programs using system ICU.
Date: Fri, 14 Apr 2017 16:51:17 +0200 [thread overview]
Message-ID: <20170414145117.27880-1-clement@lassieur.org> (raw)
In-Reply-To: <87d1chete8.fsf@gnu.org>
* gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/icu4c.scm (icu4c)[replacement]: New field.
(icu4c/fixed): New variable.
---
gnu/local.mk | 1 +
gnu/packages/icu4c.scm | 11 ++
.../icu4c-reset-keyword-list-iterator.patch | 128 +++++++++++++++++++++
3 files changed, 140 insertions(+)
create mode 100644 gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index 82e94171b..a006000a2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -657,6 +657,7 @@ dist_patch_DATA = \
%D%/packages/patches/icu4c-CVE-2014-6585.patch \
%D%/packages/patches/icu4c-CVE-2015-1270.patch \
%D%/packages/patches/icu4c-CVE-2015-4760.patch \
+ %D%/packages/patches/icu4c-reset-keyword-list-iterator.patch \
%D%/packages/patches/id3lib-CVE-2007-4460.patch \
%D%/packages/patches/ilmbase-fix-tests.patch \
%D%/packages/patches/isl-0.11.1-aarch64-support.patch \
diff --git a/gnu/packages/icu4c.scm b/gnu/packages/icu4c.scm
index d842f03b4..2b5144100 100644
--- a/gnu/packages/icu4c.scm
+++ b/gnu/packages/icu4c.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2015, 2016 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,6 +31,7 @@
(package
(name "icu4c")
(version "58.2")
+ (replacement icu4c/fixed)
(source (origin
(method url-fetch)
(uri (string-append
@@ -63,3 +65,12 @@ globalisation support for software applications. This package contains the
C/C++ part.")
(license x11)
(home-page "http://site.icu-project.org/")))
+
+(define icu4c/fixed
+ (package
+ (inherit icu4c)
+ (replacement #f)
+ (source (origin
+ (inherit (package-source icu4c))
+ (patches
+ (search-patches "icu4c-reset-keyword-list-iterator.patch"))))))
diff --git a/gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch b/gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch
new file mode 100644
index 000000000..ddedc56de
--- /dev/null
+++ b/gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch
@@ -0,0 +1,128 @@
+Copied from upstream: http://bugs.icu-project.org/trac/changeset/39484/.
+
+Paths and line endings have been adapted.
+
+Index: icu/source/common/ulist.c
+===================================================================
+--- icu/source/common/ulist.c (revision 39483)
++++ icu/source/common/ulist.c (revision 39484)
+@@ -30,5 +30,4 @@
+
+ int32_t size;
+- int32_t currentIndex;
+ };
+
+@@ -52,5 +51,4 @@
+ newList->tail = NULL;
+ newList->size = 0;
+- newList->currentIndex = -1;
+
+ return newList;
+@@ -81,6 +79,7 @@
+ p->next->previous = p->previous;
+ }
+- list->curr = NULL;
+- list->currentIndex = 0;
++ if (p == list->curr) {
++ list->curr = p->next;
++ }
+ --list->size;
+ if (p->forceDelete) {
+@@ -151,5 +150,4 @@
+ list->head->previous = newItem;
+ list->head = newItem;
+- list->currentIndex++;
+ }
+
+@@ -194,5 +192,4 @@
+ curr = list->curr;
+ list->curr = curr->next;
+- list->currentIndex++;
+
+ return curr->data;
+@@ -210,5 +207,4 @@
+ if (list != NULL) {
+ list->curr = list->head;
+- list->currentIndex = 0;
+ }
+ }
+@@ -273,3 +269,2 @@
+ return (UList *)(en->context);
+ }
+-
+Index: icu/source/i18n/ucol_res.cpp
+===================================================================
+--- icu/source/i18n/ucol_res.cpp (revision 39483)
++++ icu/source/i18n/ucol_res.cpp (revision 39484)
+@@ -681,4 +681,5 @@
+ }
+ memcpy(en, &defaultKeywordValues, sizeof(UEnumeration));
++ ulist_resetList(sink.values); // Initialize the iterator.
+ en->context = sink.values;
+ sink.values = NULL; // Avoid deletion in the sink destructor.
+Index: icu/source/test/intltest/apicoll.cpp
+===================================================================
+--- icu/source/test/intltest/apicoll.cpp (revision 39483)
++++ icu/source/test/intltest/apicoll.cpp (revision 39484)
+@@ -82,14 +82,7 @@
+ col = Collator::createInstance(Locale::getEnglish(), success);
+ if (U_FAILURE(success)){
+- errcheckln(success, "Default Collator creation failed. - %s", u_errorName(success));
+- return;
+- }
+-
+- StringEnumeration* kwEnum = col->getKeywordValuesForLocale("", Locale::getEnglish(),true,success);
+- if (U_FAILURE(success)){
+- errcheckln(success, "Get Keyword Values for Locale failed. - %s", u_errorName(success));
+- return;
+- }
+- delete kwEnum;
++ errcheckln(success, "English Collator creation failed. - %s", u_errorName(success));
++ return;
++ }
+
+ col->getVersion(versionArray);
+@@ -230,4 +223,27 @@
+ delete aFrCol;
+ delete junk;
++}
++
++void CollationAPITest::TestKeywordValues() {
++ IcuTestErrorCode errorCode(*this, "TestKeywordValues");
++ LocalPointer<Collator> col(Collator::createInstance(Locale::getEnglish(), errorCode));
++ if (errorCode.logIfFailureAndReset("English Collator creation failed")) {
++ return;
++ }
++
++ LocalPointer<StringEnumeration> kwEnum(
++ col->getKeywordValuesForLocale("collation", Locale::getEnglish(), TRUE, errorCode));
++ if (errorCode.logIfFailureAndReset("Get Keyword Values for English Collator failed")) {
++ return;
++ }
++ assertTrue("expect at least one collation tailoring for English", kwEnum->count(errorCode) > 0);
++ const char *kw;
++ UBool hasStandard = FALSE;
++ while ((kw = kwEnum->next(NULL, errorCode)) != NULL) {
++ if (strcmp(kw, "standard") == 0) {
++ hasStandard = TRUE;
++ }
++ }
++ assertTrue("expect at least the 'standard' collation tailoring for English", hasStandard);
+ }
+
+@@ -2467,4 +2483,5 @@
+ TESTCASE_AUTO_BEGIN;
+ TESTCASE_AUTO(TestProperty);
++ TESTCASE_AUTO(TestKeywordValues);
+ TESTCASE_AUTO(TestOperators);
+ TESTCASE_AUTO(TestDuplicate);
+Index: icu/source/test/intltest/apicoll.h
+===================================================================
+--- icu/source/test/intltest/apicoll.h (revision 39483)
++++ icu/source/test/intltest/apicoll.h (revision 39484)
+@@ -36,4 +36,5 @@
+ */
+ void TestProperty(/* char* par */);
++ void TestKeywordValues();
+
+ /**
--
2.12.2
next prev parent reply other threads:[~2017-04-14 14:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 10:48 bug#26462: Fix crashes in programs using system ICU Clément Lassieur
2017-04-12 10:53 ` bug#26462: [PATCH 1/2] gnu: icu4c: " Clément Lassieur
2017-04-12 10:53 ` bug#26462: [PATCH 2/2] gnu: icecat: Use " Clément Lassieur
2017-04-12 11:51 ` bug#26462: [PATCH 1/2] gnu: icu4c: Fix crashes in programs using " Ludovic Courtès
2017-04-14 14:51 ` Clément Lassieur [this message]
2017-04-16 9:54 ` bug#26462: [PATCH] " Ludovic Courtès
2017-04-17 18:45 ` Clément Lassieur
2017-04-14 14:55 ` bug#26462: [PATCH 1/2] " Clément Lassieur
2017-04-14 14:59 ` Clément Lassieur
2017-04-14 15:18 ` Ludovic Courtès
2017-04-12 10:55 ` bug#26462: " Clément Lassieur
2017-04-12 11:22 ` ng0
2017-04-12 11:31 ` Clément Lassieur
2017-04-12 11:42 ` Clément Lassieur
2017-04-12 11:53 ` ng0
2017-04-13 22:53 ` Clément Lassieur
2017-04-12 11:47 ` ng0
2017-04-13 23:01 ` Clément Lassieur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170414145117.27880-1-clement@lassieur.org \
--to=clement@lassieur.org \
--cc=26462@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).