iconv() subsystem headaches...
Hi,
I have two problems with iconv interface in glibc-2.1.1 (included in
debian-potato):
Problem A:
Synopsis: iconv_open() dumps core under some circumstances when feed with legal parameters
Severity: critical
Priority: medium
Category: libc
Class: sw-bug
Release: libc-2.1.1
Environment:
egcs-2.91.66 (1.1.2 release)
...
Description:
Second call with same parameters to iconv_open() with parameters
which results in GCONV_NOCONV coredumps. This renders iconv almost
unusable for me.
How-To-Repeat:
#include <stdio.h>
#include <iconv.h>
int main(void) {
iconv_t handle;
fprintf(stderr, "Start...\n");
handle = iconv_open("THIS_ENCODING_DOES_NOT_EXIST//", "THIS_TOO//");
fprintf(stderr, "Returned: %p, expected: %p\n", handle, (iconv_t)-1);
fprintf(stderr, "And now I core dumps...\n");
handle = iconv_open("THIS_ENCODING_DOES_NOT_EXIST//", "THIS_TOO//");
fprintf(stderr, "Um, I did not coredump? What happened?\n");
}
Fix:
Change do { ... } while (cnt > 0) to while (cnt) { .... }:
(sorry, tabs->spaces)
--- gconv_db.c.orig Thu Jan 28 17:48:11 1999
+++ gconv_db.c Mon Apr 12 13:05:18 1999
@@ -655,7 +655,7 @@
size_t cnt = *nsteps;
struct gconv_step *steps = *handle;
- do
+ while (cnt) {
if (steps[--cnt].counter++ == 0)
{
steps[cnt].shlib_handle =
@@ -670,7 +670,7 @@
break;
}
}
- while (cnt > 0);
+ };
}
#endif
Problem B:
Synopsis: Native wchar_t format is not available from iconv
Severity: non-critical
Priority: medium
Category: libc
Class: change-request
Release: libc-2.1.1
Description:
I did not found encoding which returns string in format available
by using L"Text" command of gcc; which is also only format accepted
by wcs* functions.
On big-endian, you can use UCS4, but on little-endian, you are
out of luck. For UCS2, there is UNICODEBIG and UNICODELITTLE.
Why there is not UCS4LITTLE?
Or did I miss something important?
How-To-Repeat:
N/A
Fix:
Add line
alias WCHAR_T// INTERNAL
(or something like that) into /usr/lib/gconv/gconv_modules. Because
of INTERNAL is (for this release) compatible with wchar_t, it should work.
Another fix is to remove code which adds "//" to character set name in
iconv_open() procedure.
Best regards,
Petr Vandrovec
vandrove@vc.cvut.cz
Reply to: