elf: Fix use-after-free in ldconfig [BZ #26779]
[glibc.git] / iconvdata / bug-iconv8.c
blobe32d891b5ce1eb82a700432265d985dc6eea6841
1 // BZ 12601
2 #include <stdio.h>
3 #include <errno.h>
4 #include <iconv.h>
6 static int
7 do_test (void)
9 iconv_t cd;
10 char in[] = "\x83\xd9";
11 char out[256];
12 char *inbuf;
13 size_t inbytesleft;
14 char *outbuf;
15 size_t outbytesleft;
16 size_t ret;
18 inbuf = in;
19 inbytesleft = sizeof (in) - 1;
20 outbuf = out;
21 outbytesleft = sizeof (out);
23 cd = iconv_open("utf-8", "cp932");
24 ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
25 iconv_close(cd);
27 printf("result: %zd %d %zd %d\n", ret, errno, inbytesleft, inbuf[0]);
30 * result: -1 84 0 0 (84=EILSEQ)
32 * Error is returnd but inbuf is consumed.
34 * \x83\xd9 is valid shift-jis sequence but no character is assigned
35 * to it.
38 return (ret != -1 || errno != EILSEQ
39 || inbytesleft != 2 || inbuf[0] != in[0]);
42 #define TEST_FUNCTION do_test ()
43 #include "../test-skeleton.c"