|
|
51f0aa |
commit 42d6443faf5e8b5c70474923bfcc021b77ee0095
|
|
|
51f0aa |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
51f0aa |
Date: Thu Jul 24 17:32:56 2014 +0200
|
|
|
51f0aa |
|
|
|
51f0aa |
Don't emit invalid extra shift character at block boundary by iconv (bug 17197)
|
|
|
51f0aa |
|
|
|
ce426f |
--- a/iconvdata/Makefile
|
|
|
ce426f |
+++ b/iconvdata/Makefile
|
|
|
ce426f |
@@ -67,7 +67,8 @@
|
|
|
ce426f |
|
|
|
ce426f |
ifeq (yes,$(build-shared))
|
|
|
ce426f |
tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
|
|
|
ce426f |
- tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9
|
|
|
ce426f |
+ tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \
|
|
|
ce426f |
+ bug-iconv10
|
|
|
ce426f |
ifeq ($(have-thread-library),yes)
|
|
|
ce426f |
tests += bug-iconv3
|
|
|
ce426f |
endif
|
|
|
ce426f |
@@ -286,6 +287,8 @@
|
|
|
ce426f |
$(addprefix $(objpfx),$(modules.so))
|
|
|
ce426f |
$(objpfx)bug-iconv5.out: $(objpfx)gconv-modules \
|
|
|
ce426f |
$(addprefix $(objpfx),$(modules.so))
|
|
|
ce426f |
+$(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \
|
|
|
ce426f |
+ $(addprefix $(objpfx),$(modules.so))
|
|
|
ce426f |
$(objpfx)tst-loading.out: $(objpfx)gconv-modules \
|
|
|
ce426f |
$(addprefix $(objpfx),$(modules.so))
|
|
|
ce426f |
$(objpfx)tst-iconv4.out: $(objpfx)gconv-modules \
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/iconvdata/bug-iconv10.c b/iconvdata/bug-iconv10.c
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..98353a2
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/iconvdata/bug-iconv10.c
|
|
|
ce426f |
@@ -0,0 +1,77 @@
|
|
|
ce426f |
+/* bug 17197: check for redundant shift character at block boundary.
|
|
|
ce426f |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <iconv.h>
|
|
|
ce426f |
+#include <locale.h>
|
|
|
ce426f |
+#include <stdio.h>
|
|
|
ce426f |
+#include <stdlib.h>
|
|
|
ce426f |
+#include <string.h>
|
|
|
ce426f |
+#include <errno.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+static int
|
|
|
ce426f |
+do_test (void)
|
|
|
ce426f |
+{
|
|
|
ce426f |
+ iconv_t cd = iconv_open ("IBM930", "UTF-8");
|
|
|
ce426f |
+ if (cd == (iconv_t) -1)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("iconv_open failed");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ char instr1[] = "\xc2\xa6.";
|
|
|
ce426f |
+ const char expstr1[4] = "\016Bj\017";
|
|
|
ce426f |
+ const char expstr2[] = "K";
|
|
|
ce426f |
+ char outstr[4];
|
|
|
ce426f |
+ size_t inlen = sizeof (instr1);
|
|
|
ce426f |
+ size_t outlen = sizeof (outstr);
|
|
|
ce426f |
+ char *inptr = instr1;
|
|
|
ce426f |
+ char *outptr = outstr;
|
|
|
ce426f |
+ size_t r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
|
|
|
ce426f |
+ if (r != -1
|
|
|
ce426f |
+ || errno != E2BIG
|
|
|
ce426f |
+ || inlen != sizeof (instr1) - 2
|
|
|
ce426f |
+ || inptr != instr1 + 2
|
|
|
ce426f |
+ || outlen != 0
|
|
|
ce426f |
+ || memcmp (outstr, expstr1, sizeof (expstr1)) != 0)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("wrong first conversion");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ outlen = sizeof (outstr);
|
|
|
ce426f |
+ outptr = outstr;
|
|
|
ce426f |
+ r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
|
|
|
ce426f |
+ if (r != 0
|
|
|
ce426f |
+ || inlen != 0
|
|
|
ce426f |
+ || outlen != sizeof (outstr) - sizeof (expstr2)
|
|
|
ce426f |
+ || memcmp (outstr, expstr2, sizeof (expstr2)) != 0)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("wrong second conversion");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (iconv_close (cd) != 0)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("iconv_close failed");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+ return 0;
|
|
|
ce426f |
+}
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define TEST_FUNCTION do_test ()
|
|
|
ce426f |
+#include "../test-skeleton.c"
|
|
|
ce426f |
--- a/iconvdata/ibm930.c 2015-12-01 18:13:56.799658234 -0500
|
|
|
ce426f |
+++ b/iconvdata/ibm930.c 2015-12-01 18:14:12.729906742 -0500
|
|
|
ce426f |
@@ -257,6 +257,7 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = SI; \
|
|
|
ce426f |
+ curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
if (__builtin_expect (outptr + 1 > outend, 0)) \
|
|
|
ce426f |
@@ -270,7 +271,6 @@ enum
|
|
|
ce426f |
*outptr++ = 0x5b; \
|
|
|
ce426f |
else \
|
|
|
ce426f |
*outptr++ = cp[0]; \
|
|
|
ce426f |
- curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Now that we wrote the output increment the input pointer. */ \
|
|
|
ce426f |
--- a/iconvdata/ibm933.c 2015-12-01 18:13:56.799658234 -0500
|
|
|
ce426f |
+++ b/iconvdata/ibm933.c 2015-12-01 18:14:12.729906742 -0500
|
|
|
ce426f |
@@ -255,6 +255,7 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = SI; \
|
|
|
ce426f |
+ curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
if (__builtin_expect (outptr + 1 > outend, 0)) \
|
|
|
ce426f |
@@ -263,7 +264,6 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = cp[0]; \
|
|
|
ce426f |
- curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Now that we wrote the output increment the input pointer. */ \
|
|
|
ce426f |
--- a/iconvdata/ibm935.c 2015-12-01 18:13:56.799658234 -0500
|
|
|
ce426f |
+++ b/iconvdata/ibm935.c 2015-12-01 18:14:12.729906742 -0500
|
|
|
ce426f |
@@ -255,6 +255,7 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = SI; \
|
|
|
ce426f |
+ curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
if (__builtin_expect (outptr + 1 > outend, 0)) \
|
|
|
ce426f |
@@ -263,7 +264,6 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = cp[0]; \
|
|
|
ce426f |
- curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Now that we wrote the output increment the input pointer. */ \
|
|
|
ce426f |
--- a/iconvdata/ibm937.c 2015-12-01 18:13:56.799658234 -0500
|
|
|
ce426f |
+++ b/iconvdata/ibm937.c 2015-12-01 18:14:12.729906742 -0500
|
|
|
ce426f |
@@ -255,6 +255,7 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = SI; \
|
|
|
ce426f |
+ curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
if (__builtin_expect (outptr + 1 > outend, 0)) \
|
|
|
ce426f |
@@ -263,7 +264,6 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = cp[0]; \
|
|
|
ce426f |
- curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Now that we wrote the output increment the input pointer. */ \
|
|
|
ce426f |
--- a/iconvdata/ibm939.c 2015-12-01 18:13:56.799658234 -0500
|
|
|
ce426f |
+++ b/iconvdata/ibm939.c 2015-12-01 18:14:12.739906898 -0500
|
|
|
ce426f |
@@ -255,6 +255,7 @@ enum
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
*outptr++ = SI; \
|
|
|
ce426f |
+ curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
if (__builtin_expect (outptr + 1 > outend, 0)) \
|
|
|
ce426f |
@@ -268,7 +269,6 @@ enum
|
|
|
ce426f |
*outptr++ = 0xb2; \
|
|
|
ce426f |
else \
|
|
|
ce426f |
*outptr++ = cp[0]; \
|
|
|
ce426f |
- curcs = sb; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Now that we wrote the output increment the input pointer. */ \
|