This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Out out bounds array access in ibm iconv bits


On Jul 23 2018, Jeff Law <law@redhat.com> wrote:

> So AFAICT this is a true error in the ibm iconv code spotted by Martin's
> improvements to the out of bounds array indexing warning on the gcc trunk.
>
> Building trunk glibc with a trunk gcc (any target AFAICT) on results in
> a warning like this:
>
> In file included from ibm1364.c:393,
>                  from ibm1390.c:35:
> ../iconv/skeleton.c: In function ‘gconv’:
> ../iconv/loop.c:446:274: error: array subscript 1 is outside array
> bounds of ‘unsigned char[4]’ [-Werror=array-bounds]
>        BODY

I think this should fix it:

diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
index b833273aa8..9a40940ccf 100644
--- a/iconvdata/ibm1364.c
+++ b/iconvdata/ibm1364.c
@@ -296,6 +296,7 @@ enum
 
 /* Next, define the other direction.  */
 #define MIN_NEEDED_INPUT	MIN_NEEDED_TO
+#define MAX_NEEDED_INPUT  	MAX_NEEDED_TO
 #define MIN_NEEDED_OUTPUT	MIN_NEEDED_FROM
 #define MAX_NEEDED_OUTPUT	MAX_NEEDED_FROM
 #define LOOPFCT			TO_LOOP

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]