diff options
author | Florian Weimer <fweimer@redhat.com> | 2024-09-20 13:10:54 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2024-09-20 13:51:09 +0200 |
commit | 6cbf845fcdc76131d0e674cee454fe738b69c69d (patch) | |
tree | 0287a704e978c0178178ca4521dd10e8cf6be87a /iconv/Makefile | |
parent | 00ba299787c2ea9e5c4986301e2f4965dffbfded (diff) | |
download | glibc-6cbf845fcdc76131d0e674cee454fe738b69c69d.zip glibc-6cbf845fcdc76131d0e674cee454fe738b69c69d.tar.gz glibc-6cbf845fcdc76131d0e674cee454fe738b69c69d.tar.bz2 |
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>
Diffstat (limited to 'iconv/Makefile')
-rw-r--r-- | iconv/Makefile | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/iconv/Makefile b/iconv/Makefile index b0fa550..29e4f28 100644 --- a/iconv/Makefile +++ b/iconv/Makefile @@ -61,6 +61,10 @@ test-srcs := \ tst-translit-mchar \ # test-srcs +tests-internal = \ + tst-iconv-sticky-input-error \ + # tests-internal + others = iconv_prog iconvconfig install-others-programs = $(inst_bindir)/iconv install-sbin = iconvconfig |