glibc/iconv
Stefan Liebler 876cdf517d Avoid -Wstringop-overflow= warning in iconv module.
On s390x when compiling with GCC 12, I get this warning:
utf8-utf16-z9.c:
../iconv/loop.c: In function ‘__from_utf8_loop_etf3eh_single’:
../iconv/loop.c:445:22: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  445 |     bytebuf[inlen++] = *inptr++;
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~
../iconv/loop.c:381:17: note: at offset 4 into destination object ‘bytebuf’ of size 4
  381 |   unsigned char bytebuf[MAX_NEEDED_INPUT];
      |                 ^~~~~~~
../iconv/loop.c:445:22: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  445 |     bytebuf[inlen++] = *inptr++;
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~
../iconv/loop.c:381:17: note: at offset 5 into destination object ‘bytebuf’ of size 4
  381 |   unsigned char bytebuf[MAX_NEEDED_INPUT];
      |                 ^~~~~~~

This patch tells the compiler that inend is always behind inptr which
avoids the warning.  Note that the SINGLE function is only used to
implement the mb*towc*() or wc*tomb*() functions.  Those functions use
inptr and inend pointing to a variable on stack, compute the inend pointer
or explicitly check the arguments which always leads to inptr < inend.

Special notes for backporters (according to Siddhesh Poyarekar):
If someone wants to backport this patch to release branches, they should
also backport the following wcrtomb change. Otherwise the assumptions
assumed by this patch are not true.

commit 9bcd12d223
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Fri May 13 19:10:15 2022 +0530

    wcrtomb: Make behavior POSIX compliant

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-06-14 11:03:06 +02:00
..
dummy-repertoire.c
gconv_builtin.c
gconv_builtin.h
gconv_cache.c
gconv_charset.c
gconv_charset.h
gconv_close.c
gconv_conf.c
gconv_db.c
gconv_dl.c
gconv_int.h
gconv_open.c
gconv_parseconfdir.h iconv: Use 64 bit stat for gconv_parseconfdir (BZ# 29213) 2022-06-01 13:23:16 -03:00
gconv_simple.c
gconv_trans.c
gconv.c
gconv.h
iconv_charmap.c
iconv_close.c
iconv_open.c
iconv_prog.c
iconv_prog.h
iconv.c
iconv.h
iconvconfig.c
iconvconfig.h
loop.c Avoid -Wstringop-overflow= warning in iconv module. 2022-06-14 11:03:06 +02:00
Makefile
skeleton.c
strtab.c
test-gconv-modules
tst-gconv-init-failure-mod.c
tst-gconv-init-failure.c
tst-iconv1.c
tst-iconv2.c
tst-iconv3.c
tst-iconv4.c
tst-iconv5.c
tst-iconv6.c
tst-iconv7.c
tst-iconv8.c
tst-iconv9.c
tst-iconv_prog.sh
tst-iconv-mt.c
tst-iconv-opt.c
Versions