glibc/iconv
Florian Weimer 6cbf845fcd iconv: Preserve iconv -c error exit on invalid inputs (bug 32046)
In several converters, a __GCONV_ILLEGAL_INPUT result gets overwritten
with __GCONV_FULL_OUTPUT.  As a result, iconv (the function) returns
E2BIG instead of EILSEQ.  The iconv program does not see the original
EILSEQ failure, does not recognize the invalid input, and may
incorrectly exit successfully.

To address this, a new __flags bit is used to indicate a sticky input
error state.  All __GCONV_ILLEGAL_INPUT results are replaced with a
function call that sets this new __GCONV_ENCOUNTERED_ILLEGAL_INPUT and
returns __GCONV_ILLEGAL_INPUT.  The iconv program checks for
__GCONV_ENCOUNTERED_ILLEGAL_INPUT and overrides the exit status.

The converter changes introducing __gconv_mark_illegal_input are
mostly mechanical, except for the res variable initialization in
iconvdata/iso-2022-jp.c: this error gets overwritten with __GCONV_OK
and other results in the following code.  If res ==
__GCONV_ILLEGAL_INPUT afterwards, STANDARD_TO_LOOP_ERR_HANDLER below
will handle it.

The __gconv_mark_illegal_input changes do not alter the errno value
set by the iconv function.  This is simpler to implement than
reviewing each __GCONV_FULL_OUTPUT result and adjust it not to
override a previous __GCONV_ILLEGAL_INPUT result.  Doing it that way
would also change some E2BIG errors in to EILSEQ errors, so it had to
be done conditionally (under a flag set by the iconv program only), to
avoid confusing buffer management in other applications.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-20 13:51:09 +02:00
..
dummy-repertoire.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_builtin.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_builtin.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_cache.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_charset.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_charset.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_close.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_conf.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_db.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_dl.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_int.h iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
gconv_open.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_parseconfdir.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv_simple.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
gconv_trans.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
gconv.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gconv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv_charmap.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv_close.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv_open.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv_prog.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
iconv_prog.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconvconfig.c Update copyright dates not handled by scripts/update-copyrights 2024-01-01 10:53:40 -08:00
iconvconfig.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
loop.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
Makefile iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
skeleton.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
strtab.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
test-gconv-modules Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-gconv-init-failure-mod.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-gconv-init-failure.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv1.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-iconv2.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv3.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
tst-iconv4.c [BZ #9793] 2009-02-03 01:31:30 +00:00
tst-iconv5.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv6.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv7.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv8.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv9.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv_prog-buffer.sh iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
tst-iconv_prog.sh Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv-mt.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv-opt.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-iconv-sticky-input-error.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
tst-translit-locale iconv: Fix matching of multi-character transliterations (bug 31859) 2024-08-05 16:49:57 +02:00
tst-translit-mchar.c iconv: Fix matching of multi-character transliterations (bug 31859) 2024-08-05 16:49:57 +02:00
tst-translit-mchar.sh iconv: Fix matching of multi-character transliterations (bug 31859) 2024-08-05 16:49:57 +02:00
Versions intl: Handle translation output codesets with suffixes [BZ #26383] 2020-09-25 14:47:06 +02:00