Out out bounds array access in ibm iconv bits

Message ID mvmwotk26im.fsf@suse.de
State New, archived
Headers

Commit Message

Andreas Schwab July 24, 2018, 11:54 a.m. UTC
  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:


Andreas.
  

Patch

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