[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

iconv() subsystem headaches...

  I have two problems with iconv interface in glibc-2.1.1 (included in

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
          egcs-2.91.66 (1.1.2 release)

          Second call with same parameters to iconv_open() with parameters
    which results in GCONV_NOCONV coredumps. This renders iconv almost
    unusable for me.

#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");

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 @@
-      while (cnt > 0);
+      };

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

        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?
    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

Reply to: