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