Commit Graph

26 Commits

Author SHA1 Message Date
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
Paul Eggert
dff8da6b3e Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Paul Pluzhnikov
f58a8c1c15 Fix misspellings in iconv/ and iconvdata/ -- BZ 25337
All the changes are in comments or '#error' messages.
Applying this commit results in bit-identical rebuild of iconvdata/*.so

Reviewed-by: Florian Weimer <fw@deneb.enyo.de>
2023-05-27 16:37:14 +00:00
Joseph Myers
6d7e8eda9b Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
Paul Eggert
581c785bf3 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 7061 files FOO.

I then removed trailing white space from math/tgmath.h,
support/tst-support-open-dev-null-range.c, and
sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following
obscure pre-commit check failure diagnostics from Savannah.  I don't
know why I run into these diagnostics whereas others evidently do not.

remote: *** 912-#endif
remote: *** 913:
remote: *** 914-
remote: *** error: lines with trailing whitespace found
...
remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2022-01-01 11:40:24 -08:00
Siddhesh Poyarekar
30891f35fa Remove "Contributed by" lines
We stopped adding "Contributed by" or similar lines in sources in 2012
in favour of git logs and keeping the Contributors section of the
glibc manual up to date.  Removing these lines makes the license
header a bit more consistent across files and also removes the
possibility of error in attribution when license blocks or files are
copied across since the contributed-by lines don't actually reflect
reality in those cases.

Move all "Contributed by" and similar lines (Written by, Test by,
etc.) into a new file CONTRIBUTED-BY to retain record of these
contributions.  These contributors are also mentioned in
manual/contrib.texi, so we just maintain this additional record as a
courtesy to the earlier developers.

The following scripts were used to filter a list of files to edit in
place and to clean up the CONTRIBUTED-BY file respectively.  These
were not added to the glibc sources because they're not expected to be
of any use in future given that this is a one time task:

https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc
https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-09-03 22:06:44 +05:30
Paul Eggert
2b778ceb40 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
2021-01-02 12:17:34 -08:00
Arjun Shankar
9a99c68214 iconv: Accept redundant shift sequences in IBM1364 [BZ #26224]
The IBM1364, IBM1371, IBM1388, IBM1390 and IBM1399 character sets
share converter logic (iconvdata/ibm1364.c) which would reject
redundant shift sequences when processing input in these character
sets.  This led to a hang in the iconv program (CVE-2020-27618).

This commit adjusts the converter to ignore redundant shift sequences
and adds test cases for iconv_prog hangs that would be triggered upon
their rejection.  This brings the implementation in line with other
converters that also ignore redundant shift sequences (e.g. IBM930
etc., fixed in commit 692de4b396).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-11-04 12:19:38 +01:00
Joseph Myers
d614a75396 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
Paul Eggert
5a82c74822 Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 02:43:31 -07:00
Joseph Myers
04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Andreas Schwab
21526a507d Fix out-of-bounds access in IBM-1390 converter (bug 23448)
The IBM-1390 converter can consume/produce two UCS4 characters in each
loop.
2018-07-24 16:45:46 +02:00
Joseph Myers
688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Joseph Myers
bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Joseph Myers
f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers
b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Florian Weimer
41488498b6 CVE-2014-6040: Crashes on invalid input in IBM gconv modules [BZ #17325]
These changes are based on the fix for BZ #14134 in commit
6e230d1183.
2014-09-03 19:46:42 +02:00
Steve Ellcey
13e402e77e 2014-05-01 Steve Ellcey <sellcey@mips.com>
* iconvdata/ansi_x3.110.c (ONE_DIRECTION): Define.
	* iconvdata/armscii-8.c (ONE_DIRECTION): Define.
	* iconvdata/big5.c (ONE_DIRECTION): Define.
	* iconvdata/big5hkscs.c (ONE_DIRECTION): Define.
	* iconvdata/cp1255.c (ONE_DIRECTION): Define.
	* iconvdata/cp1258.c (ONE_DIRECTION): Define.
	* iconvdata/cp932.c (ONE_DIRECTION): Define.
	* iconvdata/euc-cn.c (ONE_DIRECTION): Define.
	* iconvdata/euc-jisx0213.c (ONE_DIRECTION): Define.
	* iconvdata/euc-jp-ms.c (ONE_DIRECTION): Define.
	* iconvdata/euc-jp.c (ONE_DIRECTION): Define.
	* iconvdata/euc-kr.c (ONE_DIRECTION): Define.
	* iconvdata/euc-tw.c (ONE_DIRECTION): Define.
	* iconvdata/gb18030.c (ONE_DIRECTION): Define.
	* iconvdata/gbbig5.c (ONE_DIRECTION): Define.
	* iconvdata/gbgbk.c (ONE_DIRECTION): Define.
	* iconvdata/gbk.c (ONE_DIRECTION): Define.
	* iconvdata/ibm1364.c (ONE_DIRECTION): Define.
	* iconvdata/ibm930.c (ONE_DIRECTION): Define.
	* iconvdata/ibm932.c (ONE_DIRECTION): Define.
	* iconvdata/ibm933.c (ONE_DIRECTION): Define.
	* iconvdata/ibm935.c (ONE_DIRECTION): Define.
	* iconvdata/ibm937.c (ONE_DIRECTION): Define.
	* iconvdata/ibm939.c (ONE_DIRECTION): Define.
	* iconvdata/ibm943.c (ONE_DIRECTION): Define.
	* iconvdata/iso-2022-cn-ext.c (ONE_DIRECTION): Define.
	* iconvdata/iso-2022-cn.c (ONE_DIRECTION): Define.
	* iconvdata/iso-2022-jp-3.c (ONE_DIRECTION): Define.
	* iconvdata/iso-2022-jp.c (ONE_DIRECTION): Define.
	* iconvdata/iso-2022-kr.c (ONE_DIRECTION): Define.
	* iconvdata/iso646.c (ONE_DIRECTION): Define.
	* iconvdata/iso8859-1.c (ONE_DIRECTION): Define.
	* iconvdata/iso_11548-1.c (ONE_DIRECTION): Define.
	* iconvdata/iso_6937-2.c (ONE_DIRECTION): Define.
	* iconvdata/iso_6937.c (ONE_DIRECTION): Define.
	* iconvdata/johab.c (ONE_DIRECTION): Define.
	* iconvdata/shift_jisx0213.c (ONE_DIRECTION): Define.
	* iconvdata/sjis.c (ONE_DIRECTION): Define.
	* iconvdata/t.61.c (ONE_DIRECTION): Define.
	* iconvdata/tcvn5712-1.c (ONE_DIRECTION): Define.
	* iconvdata/tscii.c (ONE_DIRECTION): Define.
	* iconvdata/uhc.c (ONE_DIRECTION): Define.
	* iconvdata/unicode.c (ONE_DIRECTION): Define.
	* iconvdata/utf-16.c (ONE_DIRECTION): Define.
	* iconvdata/utf-32.c (ONE_DIRECTION): Define.
	* iconvdata/utf-7.c (ONE_DIRECTION): Define.
2014-05-01 13:42:40 -07:00
Ondřej Bílka
a1ffb40e32 Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
Allan McRae
d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Joseph Myers
568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Paul Eggert
59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper
4b1b449d1d 008-01-08 Jakub Jelinek <jakub@redhat.com>
* iconv/loop.c (UPDATE_PARAMS): Define to empty statement if not
	defined.
	(REINIT_PARAMS): Likewise.  Undefine before end of file.
	(STANDARD_TO_LOOP_ERR_HANDLER): Use UPDATE_PARAMS before calling
	transliteration hooks and REINIT_PARAMS afterwards.
	* iconvdata/iso-2022-jp.c (BODY): Use a separate variable for
	status.
	(REINIT_PARAMS): Define.
	* iconvdata/ibm1364.c (REINIT_PARAMS): Likewise.
	* iconvdata/ibm930.c (REINIT_PARAMS): Likewise.
	* iconvdata/ibm933.c (REINIT_PARAMS): Likewise.
	* iconvdata/ibm935.c (REINIT_PARAMS): Likewise.
	* iconvdata/ibm937.c (REINIT_PARAMS): Likewise.
	* iconvdata/ibm939.c (REINIT_PARAMS): Likewise.
	* iconvdata/iso-2022-cn.c (REINIT_PARAMS): Likewise.
	* iconvdata/iso-2022-cn-ext.c (REINIT_PARAMS): Likewise.
	* iconvdata/iso-2022-jp-3.c (REINIT_PARAMS): Likewise.
	* iconvdata/iso-2022-kr.c (REINIT_PARAMS): Likewise.
	* iconvdata/Makefile: Add rules to build and run tst-iconv7.c.
	* iconvdata/tst-iconv7.c: New test.
2008-01-09 20:03:58 +00:00
Ulrich Drepper
ad1df11413 iconv module for IBM1364. 2005-10-19 23:31:17 +00:00
Ulrich Drepper
a334319f65 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. 2004-12-22 20:10:10 +00:00
Jakub Jelinek
0ecb606cb6 2.5-18.1 2007-07-12 18:26:36 +00:00