This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12601] New: iconv(3) doesn't handle invalid sequence properly


http://sourceware.org/bugzilla/show_bug.cgi?id=12601

           Summary: iconv(3) doesn't handle invalid sequence properly
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: yukihiro.nakadaira@gmail.com


When converting from cp932, iconv() doesn't handle invalid sequence properly.
See the following code.
iconv() returns -1 but inbuf is consumed.

I think it is the same issue with this.
http://sourceware.org/ml/libc-hacker/2009-04/msg00005.html
https://bugzilla.redhat.com/show_bug.cgi?id=497267



#include <stdio.h>
#include <errno.h>
#include <iconv.h>

int main()
{
    iconv_t cd;
    char in[] = "\x83\xd9";
    char out[256];
    char *inbuf;
    size_t inbytesleft;
    char *outbuf;
    size_t outbytesleft;
    size_t ret;

    inbuf = in;
    inbytesleft = sizeof(in) - 1;
    outbuf = out;
    outbytesleft = sizeof(out);

    cd = iconv_open("utf-8", "cp932");
    ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
    iconv_close(cd);

    printf("result: %ld %d %ld %d\n", ret, errno, inbytesleft, inbuf[0]);

    /*
     * result: -1 84 0 0        (84=EILSEQ)
     *
     * Error is returnd but inbuf is consumed.
     *
     * \x83\xd9 is valid shift-jis sequence but no character is assigned
     * to it.
     */

    return 0;
}

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]