2014-09-03  Florian Weimer  <fweimer@redhat.com>

	[BZ #17325]
	* iconvdata/ibm1364.c (BODY): Fix check for sentinel.
	* iconvdata/ibm932.c (BODY): Replace invalid sentinel check with
	assert.
	* iconvdata/ibm933.c (BODY): Fix check for sentinel.
	* iconvdata/ibm935.c (BODY): Likewise.
	* iconvdata/ibm937.c (BODY): Likewise.
	* iconvdata/ibm939.c (BODY): Likewise.
	* iconvdata/ibm943.c (BODY): Replace invalid sentinel check with
	assert.

Index: glibc-2.19/iconvdata/ibm1364.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm1364.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm1364.c	2014-11-28 10:46:39.041255818 -0500
@@ -220,7 +220,8 @@
 	  ++rp2;							      \
 									      \
 	uint32_t res;							      \
-	if (__builtin_expect (ch < rp2->start, 0)			      \
+	if (__builtin_expect (rp2->start == 0xffff, 0)			      \
+	    || __builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = DB_TO_UCS4[ch + rp2->idx],			      \
 		__builtin_expect (res, L'\1') == L'\0' && ch != '\0'))	      \
 	  {								      \
Index: glibc-2.19/iconvdata/ibm932.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm932.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm932.c	2014-11-28 10:46:39.041255818 -0500
@@ -73,11 +73,12 @@
 	  }								      \
 									      \
 	ch = (ch * 0x100) + inptr[1];					      \
+	/* ch was less than 0xfd.  */					      \
+	assert (ch < 0xfd00);						      \
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
-	    || __builtin_expect (ch < rp2->start, 0)			      \
+	if (__builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm932db_to_ucs4[ch + rp2->idx],		      \
 	    __builtin_expect (res, '\1') == 0 && ch !=0))		      \
 	  {								      \
Index: glibc-2.19/iconvdata/ibm933.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm933.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm933.c	2014-11-28 10:46:39.041255818 -0500
@@ -161,7 +161,7 @@
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
+	if (__builtin_expect (rp2->start == 0xffff, 0)			      \
 	    || __builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm933db_to_ucs4[ch + rp2->idx],		      \
 		__builtin_expect (res, L'\1') == L'\0' && ch != '\0'))	      \
Index: glibc-2.19/iconvdata/ibm935.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm935.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm935.c	2014-11-28 10:46:39.041255818 -0500
@@ -161,7 +161,7 @@
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
+	if (__builtin_expect (rp2->start == 0xffff, 0)			      \
 	    || __builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm935db_to_ucs4[ch + rp2->idx],		      \
 		__builtin_expect (res, L'\1') == L'\0' && ch != '\0'))	      \
Index: glibc-2.19/iconvdata/ibm937.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm937.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm937.c	2014-11-28 10:46:39.041255818 -0500
@@ -161,7 +161,7 @@
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
+	if (__builtin_expect (rp2->start == 0xffff, 0)			      \
 	    || __builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm937db_to_ucs4[ch + rp2->idx],		      \
 		__builtin_expect (res, L'\1') == L'\0' && ch != '\0'))	      \
Index: glibc-2.19/iconvdata/ibm939.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm939.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm939.c	2014-11-28 10:46:39.041255818 -0500
@@ -161,7 +161,7 @@
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
+	if (__builtin_expect (rp2->start == 0xffff, 0)			      \
 	    || __builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm939db_to_ucs4[ch + rp2->idx],		      \
 		__builtin_expect (res, L'\1') == L'\0' && ch != '\0'))	      \
Index: glibc-2.19/iconvdata/ibm943.c
===================================================================
--- glibc-2.19.orig/iconvdata/ibm943.c	2014-11-28 10:46:39.045255850 -0500
+++ glibc-2.19/iconvdata/ibm943.c	2014-11-28 10:46:39.041255818 -0500
@@ -74,11 +74,12 @@
 	  }								      \
 									      \
 	ch = (ch * 0x100) + inptr[1];					      \
+	/* ch was less than 0xfd.  */					      \
+	assert (ch < 0xfd00);						      \
 	while (ch > rp2->end)						      \
 	  ++rp2;							      \
 									      \
-	if (__builtin_expect (rp2 == NULL, 0)				      \
-	    || __builtin_expect (ch < rp2->start, 0)			      \
+	if (__builtin_expect (ch < rp2->start, 0)			      \
 	    || (res = __ibm943db_to_ucs4[ch + rp2->idx],		      \
 	    __builtin_expect (res, '\1') == 0 && ch !=0))		      \
 	  {								      \
