glibc/iconvdata
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
..
testdata
8bit-gap.c
8bit-generic.c
ansi_x3.110.c
armscii-8.c
ARMSCII-8.irreversible
asmo_449.c
big5.c
big5hkscs.c
BIG5.irreversible
BIG5HKSCS.irreversible
BIG5HKSCS.precomposed
brf.c
bug-iconv1.c
bug-iconv2.c
bug-iconv3.c
bug-iconv4.c
bug-iconv5.c
bug-iconv6.c
bug-iconv8.c
bug-iconv9.c
bug-iconv10.c
bug-iconv11.c
bug-iconv12.c
bug-iconv13.c
bug-iconv14.c
bug-iconv15.c
cns11643.c
cns11643.h
cns11643l1.c
cns11643l1.h
cns11643l2.h
cp737.c
cp737.h
cp770.c
cp771.c
cp772.c
cp773.c
cp774.c
cp775.c
cp775.h
cp932.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
cp1125.c
cp1250.c
cp1251.c
cp1252.c
cp1253.c
cp1254.c
cp1255.c
cp1256.c
cp1257.c
cp1258.c
cp10007.c
CP932.irreversible
CP1255.irreversible
CP1258.irreversible
csn_369103.c
cwi.c
dec-mcs.c
Depend
ebcdic-at-de-a.c
ebcdic-at-de.c
ebcdic-ca-fr.c
ebcdic-dk-no-a.c
ebcdic-dk-no.c
ebcdic-es-a.c
ebcdic-es-s.c
ebcdic-es.c
ebcdic-fi-se-a.c
ebcdic-fi-se.c
ebcdic-fr.c
ebcdic-is-friss.c
ebcdic-it.c
ebcdic-pt.c
ebcdic-uk.c
ebcdic-us.c
ecma-cyrillic.c
euc-cn.c
euc-jisx0213.c
EUC-JISX0213.precomposed
euc-jp-ms.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
EUC-JP-MS.irreversible
euc-jp.c
EUC-JP.irreversible
euc-kr.c
EUC-KR.irreversible
euc-tw.c
EUC-TW.irreversible
extra-module.mk
gap.awk
gaptab.awk
gb2312.c
gb2312.h
gb18030.c
gbbig5.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
gbgbk.c
gbk.c
gconv-modules
gconv-modules-extra.conf
gconv.map
gen-8bit-gap-1.sh
gen-8bit-gap.sh
gen-8bit.sh
georgian-academy.c
georgian-ps.c
gost_19768-74.c
greek7-old.c
greek7.c
greek-ccitt.c
hp-greek8.c
hp-roman8.c
hp-roman9.c
hp-thai8.c
hp-turkish8.c
ibm037.c
ibm038.c
ibm256.c
ibm273.c
ibm274.c
ibm275.c
ibm277.c
ibm278.c
ibm280.c
ibm281.c
ibm284.c
ibm285.c
ibm290.c
ibm297.c
ibm420.c
ibm423.c
ibm424.c
ibm437.c
ibm500.c
ibm803.c
ibm803.h
ibm850.c
ibm851.c
ibm852.c
ibm855.c
ibm856.c
ibm856.h
ibm857.c
ibm858.c
ibm860.c
ibm861.c
ibm862.c
ibm863.c
ibm864.c
ibm865.c
ibm866.c
ibm866nav.c
ibm868.c
ibm869.c
ibm870.c
ibm871.c
ibm874.c
ibm875.c
ibm880.c
ibm891.c
ibm901.c
ibm901.h
ibm902.c
ibm902.h
ibm903.c
ibm904.c
ibm905.c
ibm918.c
ibm921.c
ibm921.h
ibm922.c
ibm922.h
ibm930.c
ibm930.h
ibm932.c
ibm932.h
ibm933.c
ibm933.h
ibm935.c
ibm935.h
ibm937.c
ibm937.h
ibm939.c
ibm939.h
ibm943.c
ibm943.h
ibm1004.c
ibm1008_420.c
ibm1008.c
ibm1008.h
ibm1025.c
ibm1025.h
ibm1026.c
ibm1046.c
ibm1046.h
ibm1047.c
ibm1097.c
ibm1097.h
ibm1112.c
ibm1112.h
ibm1122.c
ibm1122.h
ibm1123.c
ibm1123.h
ibm1124.c
ibm1124.h
ibm1129.c
ibm1129.h
ibm1130.c
ibm1130.h
ibm1132.c
ibm1132.h
ibm1133.c
ibm1133.h
ibm1137.c
ibm1137.h
ibm1140.c
ibm1140.h
ibm1141.c
ibm1141.h
ibm1142.c
ibm1142.h
ibm1143.c
ibm1143.h
ibm1144.c
ibm1144.h
ibm1145.c
ibm1145.h
ibm1146.c
ibm1146.h
ibm1147.c
ibm1147.h
ibm1148.c
ibm1148.h
ibm1149.c
ibm1149.h
ibm1153.c
ibm1153.h
ibm1154.c
ibm1154.h
ibm1155.c
ibm1155.h
ibm1156.c
ibm1156.h
ibm1157.c
ibm1157.h
ibm1158.c
ibm1158.h
ibm1160.c
ibm1160.h
ibm1161.c
ibm1161.h
ibm1162.c
ibm1162.h
ibm1163.c
ibm1163.h
ibm1164.c
ibm1164.h
ibm1166.c
ibm1166.h
ibm1167.c
ibm1167.h
ibm1364.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
ibm1364.h
ibm1371.c
ibm1371.h
ibm1388.c
ibm1388.h
ibm1390.c
ibm1390.h
ibm1399.c
ibm1399.h
ibm4517.c
ibm4517.h
ibm4899.c
ibm4899.h
ibm4909.c
ibm4909.h
ibm4971.c
ibm4971.h
ibm5347.c
ibm5347.h
ibm9030.c
ibm9030.h
ibm9066.c
ibm9066.h
ibm9448.c
ibm9448.h
ibm12712.c
ibm12712.h
ibm16804.c
ibm16804.h
IBM856.irreversible
IBM922.irreversible
IBM1132.irreversible
IBM1133.irreversible
IBM1160.irreversible
IBM1161.irreversible
IBM1163.irreversible
IBM1164.irreversible
iec_p27-1.c
inis-8.c
inis-cyrillic.c
inis.c
isiri-3342.c
isiri-3342.h
ISIRI-3342.irreversible
iso646.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
iso8859-1.c
iso8859-2.c
iso8859-3.c
iso8859-4.c
iso8859-5.c
iso8859-6.c
iso8859-7.c
iso8859-8.c
iso8859-9.c
iso8859-9e.c
iso8859-10.c
iso8859-11.c
iso8859-13.c
iso8859-14.c
iso8859-15.c
iso8859-16.c
iso_2033.c
iso_5427-ext.c
iso_5427.c
iso_5428.c
iso_6937-2.c
iso_6937.c
iso_10367-box.c
iso_11548-1.c
iso-2022-cn-ext.c
iso-2022-cn.c
iso-2022-jp-3.c
iso-2022-jp.c
iso-2022-kr.c
iso-ir-165.c
iso-ir-165.h
iso-ir-197.c
iso-ir-209.c
jis0201.c
jis0201.h
jis0208.c
jis0208.h
jis0212.c
jis0212.h
jisx0213.c
jisx0213.h
JISX0213.TXT
johab.c
koi8-r.c
koi8-ru.c
koi8-t.c
koi8-u.c
koi-8.c
ksc5601.c
ksc5601.h
latin-greek-1.c
latin-greek.c
mac-centraleurope.c
mac-is.c
mac-sami.c
mac-uk.c
macintosh.c
Makefile
mik.c
MISSING
nats-dano.c
nats-sefi.c
pt154.c
rk1048.c
run-iconv-test.sh
sami-ws2.c
shift_jisx0213.c
SHIFT_JISX0213.irreversible
SHIFT_JISX0213.precomposed
sjis.c
SJIS.irreversible
t.61.c
tcvn5712-1.c
TCVN5712-1.precomposed
TESTS
TESTS2
tis-620.c
tscii.c
TSCII.irreversible
TSCII.precomposed
tst-e2big.c
tst-iconv4.c
tst-iconv6.c
tst-iconv7.c
tst-iconv-big5-hkscs-to-2ucs4.c
tst-iconv-iso-2022-cn-ext.c
tst-loading.c
tst-table-charmap.sh
tst-table-from.c
tst-table-to.c
tst-table.sh
tst-tables.sh
uhc.c
unicode.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
utf-7.c
utf-16.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
utf-32.c iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
viscii.c