From 91927b7c76437db860cd86a7714476b56bb39d07 Mon Sep 17 00:00:00 2001 From: Arjun Shankar Date: Tue, 7 Jul 2020 20:31:48 +0200 Subject: Rewrite iconv option parsing [BZ #19519] This commit replaces string manipulation during `iconv_open' and iconv_prog option parsing with a structured, flag based conversion specification. In doing so, it alters the internal `__gconv_open' interface and accordingly adjusts its uses. This change fixes several hangs in the iconv program and therefore includes a new test to exercise iconv_prog options that originally led to these hangs. It also includes a new regression test for option handling in the iconv function. Reviewed-by: Florian Weimer Reviewed-by: Siddhesh Poyarekar Reviewed-by: Carlos O'Donell --- intl/dcigettext.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'intl/dcigettext.c') diff --git a/intl/dcigettext.c b/intl/dcigettext.c index 465c8df..2e7c662 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1119,11 +1119,16 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, outcharset = encoding; # ifdef _LIBC - /* We always want to use transliteration. */ - outcharset = norm_add_slashes (outcharset, "TRANSLIT"); - charset = norm_add_slashes (charset, ""); - int r = __gconv_open (outcharset, charset, &convd->conv, - GCONV_AVOID_NOCONV); + + struct gconv_spec conv_spec + = { .fromcode = norm_add_slashes (charset, ""), + .tocode = norm_add_slashes (outcharset, ""), + /* We always want to use transliteration. */ + .translit = true, + .ignore = false + }; + int r = __gconv_open (&conv_spec, &convd->conv, + GCONV_AVOID_NOCONV); if (__builtin_expect (r != __GCONV_OK, 0)) { /* If the output encoding is the same there is -- cgit v1.1