Upgrade to 2.0.5 (#1577864, #1579825)

This commit is contained in:
Robert Scheck 2018-05-21 01:11:43 +02:00
parent b31e43be0d
commit 7971c54549
4 changed files with 11 additions and 381 deletions

View File

@ -1,259 +0,0 @@
From 6fa9aa172ba262356502aec2a3047610251c6093 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Fri, 16 Mar 2018 10:59:39 +0100
Subject: [PATCH] Return error (IDN2_ICOV_FAIL) on charset conversion errors
---
lib/decode.c | 36 +++++++++++++++++++++++++++---------
lib/lookup.c | 7 +++++--
lib/register.c | 8 ++++++--
src/idn2.c | 3 ++-
tests/test-tounicode.c | 21 ++++++++++++---------
5 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/lib/decode.c b/lib/decode.c
index f55d029..f15d39e 100644
--- a/lib/decode.c
+++ b/lib/decode.c
@@ -356,20 +356,34 @@ idn2_to_unicode_8zlz (const char * input, char ** output, int flags)
{
int rc;
uint8_t *output_u8, *output_l8;
+ const char *encoding;
rc = idn2_to_unicode_8z8z (input, (char **) &output_u8, flags);
if (rc != IDN2_OK || !input)
return rc;
- output_l8 = (uint8_t*)u8_strconv_to_locale (output_u8);
- free (output_u8);
+ encoding = locale_charset ();
+ output_l8 = (uint8_t*) u8_strconv_to_encoding (output_u8, encoding, iconveh_error);
- if (output)
- *output = (char *) output_l8;
+ if (!output_l8)
+ {
+ if (errno == ENOMEM)
+ rc = IDN2_MALLOC;
+ else
+ rc = IDN2_ENCODING_ERROR;
+
+ free(output_l8);
+ }
else
- free (output_l8);
+ {
+ if (output)
+ *output = (char *) output_l8;
+ rc = IDN2_OK;
+ }
- return IDN2_OK;
+ free (output_u8);
+
+ return rc;
}
/**
@@ -389,7 +403,8 @@ idn2_to_unicode_8zlz (const char * input, char ** output, int flags)
* %IDN2_OK: The conversion was successful.
* %IDN2_TOO_BIG_DOMAIN: The domain is too long.
* %IDN2_TOO_BIG_LABEL: A label is would have been too long.
- * %IDN2_ENCODING_ERROR: Character conversion failed.
+ * %IDN2_ENCODING_ERROR: Output character conversion failed.
+ * %IDN2_ICONV_FAIL: Input character conversion failed.
* %IDN2_MALLOC: Memory allocation failed.
*
* Since: 2.0.0
@@ -398,6 +413,7 @@ int
idn2_to_unicode_lzlz (const char * input, char ** output, int flags)
{
uint8_t *input_l8;
+ const char *encoding;
int rc;
if (!input)
@@ -407,12 +423,14 @@ idn2_to_unicode_lzlz (const char * input, char ** output, int flags)
return IDN2_OK;
}
- input_l8 = u8_strconv_from_locale (input);
+ encoding = locale_charset ();
+ input_l8 = u8_strconv_from_encoding (input, encoding, iconveh_error);
+
if (!input_l8)
{
if (errno == ENOMEM)
return IDN2_MALLOC;
- return IDN2_ENCODING_ERROR;
+ return IDN2_ICONV_FAIL;
}
rc = idn2_to_unicode_8zlz ((char*)input_l8, output, flags);
diff --git a/lib/lookup.c b/lib/lookup.c
index 9094aeb..e64182a 100644
--- a/lib/lookup.c
+++ b/lib/lookup.c
@@ -514,8 +514,11 @@ idn2_lookup_ul (const char * src, char ** lookupname, int flags)
if (src)
{
- utf8src = u8_strconv_from_locale (src);
- if (utf8src == NULL)
+ const char *encoding = locale_charset ();
+
+ utf8src = u8_strconv_from_encoding (src, encoding, iconveh_error);
+
+ if (!utf8src)
{
if (errno == ENOMEM)
return IDN2_MALLOC;
diff --git a/lib/register.c b/lib/register.c
index 910ff18..5407ea2 100644
--- a/lib/register.c
+++ b/lib/register.c
@@ -231,7 +231,8 @@ idn2_register_u8 (const uint8_t * ulabel, const uint8_t * alabel,
* %IDN2_UALABEL_MISMATCH is returned, when either of the input
* labels are too long %IDN2_TOO_BIG_LABEL is returned, when @alabel
* does does not appear to be a proper A-label %IDN2_INVALID_ALABEL
- * is returned, or another error code is returned.
+ * is returned, when @ulabel locale to UTF-8 conversion failed
+ * %IDN2_ICONV_FAIL is returned, or another error code is returned.
**/
int
idn2_register_ul (const char *ulabel, const char *alabel,
@@ -242,7 +243,10 @@ idn2_register_ul (const char *ulabel, const char *alabel,
if (ulabel)
{
- utf8ulabel = u8_strconv_from_locale (ulabel);
+ const char *encoding = locale_charset ();
+
+ utf8ulabel = u8_strconv_from_encoding (ulabel, encoding, iconveh_error);
+
if (utf8ulabel == NULL)
{
if (errno == ENOMEM)
diff --git a/src/idn2.c b/src/idn2.c
index 4a13a82..906ae01 100644
--- a/src/idn2.c
+++ b/src/idn2.c
@@ -108,8 +108,9 @@ hexdump (const char *prefix, const char *str)
uint32_t *u32;
size_t u32len;
size_t i;
+ const char *encoding = locale_charset ();
- u8 = u8_strconv_from_locale (str);
+ u8 = u8_strconv_from_encoding (str, encoding, iconveh_error);
if (u8)
u32 = u8_to_u32 (u8, strlen ((char *) u8), NULL, &u32len);
diff --git a/tests/test-tounicode.c b/tests/test-tounicode.c
index a0ede86..9f77779 100644
--- a/tests/test-tounicode.c
+++ b/tests/test-tounicode.c
@@ -262,7 +262,7 @@ const test_t test[] = {
{
0
},
- IDN2_ENCODING_ERROR
+ IDN2_ENCODING_ERROR /* or IDN2_ICONV_FAIL with idn2_to_unicode_lzlz() due to bad UTF-8 input */
},
/* Test vectors from https://bugs.debian.org/610617 */
@@ -352,7 +352,7 @@ const test_t test[] = {
},
};
-static int debug = 0;
+static int debug = 1;
static int error_count = 0;
static int break_on_error = 0;
@@ -406,10 +406,11 @@ _u32_strcmp(const uint32_t *s1, const uint32_t *s2)
static void
_check_4z(const test_t *t, int rc, uint32_t *ucs4, const char *funcname)
{
- if (rc != t->rc_expected)
+ if (rc != t->rc_expected && !(rc == IDN2_ICONV_FAIL && t->rc_expected == IDN2_ENCODING_ERROR))
{
- fail ("%s() entry %u failed: %s\n",
- funcname, (unsigned) (t - test), idn2_strerror (rc));
+ fprintf (stderr, "Test[%u] '%s' failed (got %d, expected %d):\n",
+ (unsigned) (t - test), t->name, rc, t->rc_expected);
+ fail (" %s(): %s\n", funcname, idn2_strerror (rc));
}
else if (rc == IDN2_OK)
{
@@ -443,6 +444,7 @@ main (void)
uint32_t *ucs4, *punycode_u32;
uint8_t *utf8;
char *utf8_lz;
+ const char *encoding;
size_t outlen, outlen2;
int rc, skip_lz = 0;
unsigned i;
@@ -451,11 +453,12 @@ main (void)
* At least on Debian with libunistring 0.9.6+really0.9.3-0.1 and LC_ALL=C valgrind
* reports Conditional jump or move depends on uninitialised value */
setlocale (LC_ALL, "C.UTF-8");
+ encoding = locale_charset();
if (debug)
- printf("charset=%s\n", locale_charset());
+ printf("charset=%s\n", encoding);
- if (strcmp(locale_charset(), "UTF-8") != 0)
+ if (strcmp(encoding, "UTF-8") != 0)
skip_lz = 1;
for (i = 0; i < sizeof (test) / sizeof (test[0]); i++)
@@ -503,7 +506,7 @@ main (void)
rc = idn2_to_unicode_8zlz (t->punycode, &utf8_lz, 0);
if (rc == IDN2_OK)
{
- utf8 = u8_strconv_from_locale (utf8_lz);
+ utf8 = u8_strconv_from_encoding (utf8_lz, encoding, iconveh_error);
free (utf8_lz);
ucs4 = u8_to_u32 (utf8, u8_strlen (utf8) + 1, NULL, &outlen);
free (utf8);
@@ -517,7 +520,7 @@ main (void)
rc = idn2_to_unicode_lzlz (t->punycode, (char **) &utf8_lz, 0);
if (rc == IDN2_OK)
{
- utf8 = u8_strconv_from_locale (utf8_lz);
+ utf8 = u8_strconv_from_encoding (utf8_lz, encoding, iconveh_error);
free (utf8_lz);
ucs4 = u8_to_u32 (utf8, u8_strlen (utf8) + 1, NULL, &outlen);
free (utf8);
--
libgit2 0.26.0
From dd11133faa276744fb2b11424778c62820bbd547 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Fri, 16 Mar 2018 11:18:02 +0100
Subject: [PATCH] Fix memleak in idn2_to_unicode_8zlz()
---
lib/decode.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/decode.c b/lib/decode.c
index f15d39e..db80d65 100644
--- a/lib/decode.c
+++ b/lib/decode.c
@@ -378,6 +378,9 @@ idn2_to_unicode_8zlz (const char * input, char ** output, int flags)
{
if (output)
*output = (char *) output_l8;
+ else
+ free (output_l8);
+
rc = IDN2_OK;
}
--
libgit2 0.26.0

View File

@ -1,107 +0,0 @@
From 31b11be35dd841dc1a97c45321b22c3376b01031 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Thu, 8 Feb 2018 12:52:06 +0100
Subject: [PATCH] Fix STD3 ASCII rules
---
lib/idna.c | 15 ++++++++++++++-
lib/lookup.c | 5 ++++-
tests/test-lookup.c | 9 ++++++++-
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/lib/idna.c b/lib/idna.c
index 5434492..c961332 100644
--- a/lib/idna.c
+++ b/lib/idna.c
@@ -180,7 +180,20 @@ _idn2_label_test (int what, const uint32_t * label, size_t llen)
size_t i;
for (i = 0; i < llen; i++)
if (_idn2_disallowed_p (label[i]))
- return IDN2_DISALLOWED;
+ {
+ if ((what & (TEST_TRANSITIONAL | TEST_NONTRANSITIONAL)) &&
+ (what & TEST_ALLOW_STD3_DISALLOWED))
+ {
+ IDNAMap map;
+ get_idna_map (label[i], &map);
+ if (map_is (&map, TR46_FLG_DISALLOWED_STD3_VALID) ||
+ map_is (&map, TR46_FLG_DISALLOWED_STD3_MAPPED))
+ continue;
+
+ }
+
+ return IDN2_DISALLOWED;
+ }
}
if (what & TEST_CONTEXTJ)
diff --git a/lib/lookup.c b/lib/lookup.c
index 10b004f..9094aeb 100644
--- a/lib/lookup.c
+++ b/lib/lookup.c
@@ -89,7 +89,10 @@ label (const uint8_t * src, size_t srclen, uint8_t * dst, size_t * dstlen,
TEST_DISALLOWED |
TEST_CONTEXTJ_RULE |
TEST_CONTEXTO_WITH_RULE |
- TEST_UNASSIGNED | TEST_BIDI, p, plen);
+ TEST_UNASSIGNED | TEST_BIDI |
+ ((flags & IDN2_NONTRANSITIONAL) ? TEST_NONTRANSITIONAL : 0) |
+ ((flags & IDN2_USE_STD3_ASCII_RULES) ? 0 : TEST_ALLOW_STD3_DISALLOWED),
+ p, plen);
if (rc != IDN2_OK)
{
diff --git a/tests/test-lookup.c b/tests/test-lookup.c
index 03d8396..fb23427 100644
--- a/tests/test-lookup.c
+++ b/tests/test-lookup.c
@@ -814,13 +814,20 @@ static const struct idna idna[] = {
},
/* √.com */
{"\xe2\x88\x9a.com", "xn--19g.com", IDN2_OK, IDN2_TRANSITIONAL},
- /* domains with non-STD3 characters (removed by default when using TR46 transitional/non-trnasitional */
+ /* domains with non-STD3 characters (removed by default when using TR46 transitional/non-transitional */
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, 0},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
+ /* _üˆš */
+ {"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, 0},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_TRANSITIONAL},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_NONTRANSITIONAL},
+ {"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
+ {"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
};
static int ok = 0, failed = 0;
--
libgit2 0.26.0
From f09a3c4657838e63751f9cd0c6c2b4f7485b68e9 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Sun, 18 Feb 2018 18:38:25 +0100
Subject: [PATCH] Fix idn2 --nostd3asciirules to --usestd3asciirules
---
src/idn2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/idn2.c b/src/idn2.c
index a3e19c0..4a13a82 100644
--- a/src/idn2.c
+++ b/src/idn2.c
@@ -92,7 +92,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
--no-tr46 Disable TR46 processing\n\
"), stdout);
fputs (_("\
- --nostd3asciirules Disable STD3 ASCII rules\n\
+ --usestd3asciirules Enable STD3 ASCII rules\n\
--debug Print debugging information\n\
--quiet Silent operation\n\
"), stdout);
--
libgit2 0.26.0

View File

@ -1,17 +1,16 @@
Summary: Library to support IDNA2008 internationalized domain names
Name: libidn2
Version: 2.0.4
Release: 7%{?dist}
Version: 2.0.5
Release: 1%{?dist}
License: (GPLv2+ or LGPLv3+) and GPLv3+
URL: https://www.gnu.org/software/libidn/#libidn2
Source0: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz
Source1: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz.sig
Patch0: libidn2-2.0.0-rpath.patch
Patch1: libidn2-2.0.4-std3-ascii-rules.patch
Patch2: libidn2-2.0.4-idn2-iconv-fail.patch
BuildRequires: gcc
BuildRequires: gettext
BuildRequires: libunistring-devel
Requires(post): /sbin/install-info, /sbin/ldconfig
Requires(preun): /sbin/install-info
@ -45,14 +44,6 @@ IDNA2008 conversions.
%patch0 -p1 -b .rpath
touch -c -r configure.rpath configure
touch -c -r m4/libtool.m4.rpath m4/libtool.m4
%patch1 -p1 -b .std3-ascii-rules
touch -c -r lib/idna.c.std3-ascii-rules lib/idna.c
touch -c -r lib/lookup.c.std3-ascii-rules lib/lookup.c
touch -c -r tests/test-lookup.c.std3-ascii-rules tests/test-lookup.c
%patch2 -p1 -b .idn2-iconv-fail
touch -c -r lib/decode.c.idn2-iconv-fail lib/decode.c
touch -c -r lib/lookup.c.idn2-iconv-fail lib/lookup.c
touch -c -r lib/register.c.idn2-iconv-fail lib/register.c
%build
%configure --disable-static
@ -71,6 +62,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
# Some file cleanups
rm -f $RPM_BUILD_ROOT%{_datadir}/info/dir
%find_lang %{name}
%check
make %{?_smp_mflags} -C tests check
@ -86,7 +79,7 @@ if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/%{name}.info.gz %{_infodir}/dir || :
fi
%files
%files -f %{name}.lang
%license COPYING COPYING.LESSERv3 COPYING.unicode COPYINGv2
%doc AUTHORS NEWS README.md
%{_libdir}/%{name}.so.*
@ -105,6 +98,9 @@ fi
%{_infodir}/%{name}.info*
%changelog
* Mon May 21 2018 Robert Scheck <robert@fedoraproject.org> 2.0.5-1
- Upgrade to 2.0.5 (#1577864, #1579825)
* Wed Apr 04 2018 Robert Scheck <robert@fedoraproject.org> 2.0.4-7
- Split RPM scriptlets (#1563832)

View File

@ -1,2 +1,2 @@
SHA512 (libidn2-2.0.4.tar.gz) = 1e51bd4b8f8907531576291f1c2a8865d17429b4105418b4c98754eb982cd1cbb3adbeab4ec0c1c561d2dba11d876c7c09e5dc5b315c55a2c24986d7a2a3b4d2
SHA512 (libidn2-2.0.4.tar.gz.sig) = 8b30f47837ed451b9ee0ab1bf474861691084205012763f5a9219adb5f06f02cc7b4e6e9dc2e3a980c92c0e27877c03db57e585f88ba4cadbdcd1a4f68264951
SHA512 (libidn2-2.0.5.tar.gz) = 9d040d60de40316788825d8720d509d5b8a82287415e09e17792c2f32fad99ca77f43e55888b9484db69426eaa0ece59e9671eee9cc46411afbdb0f81af31a79
SHA512 (libidn2-2.0.5.tar.gz.sig) = 45959aa20bcafb97deaba56ccb1eadaf82f20b11984ed92c8c9f5ff942633f11e3bcc34682a2855c36131aac6eb9ad6ea8b060a83daa9a872d44f030baeda49f