Bug 497267 - Bug in SHIFT_JIS EILSEQ handling
Summary: Bug in SHIFT_JIS EILSEQ handling
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-23 05:18 UTC by Behdad Esfahbod
Modified: 2009-04-27 20:21 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-04-27 20:11:21 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
test case (948 bytes, text/plain)
2009-04-23 22:51 UTC, Behdad Esfahbod
no flags Details

Description Behdad Esfahbod 2009-04-23 05:18:29 UTC
Trying to convert the invalid sequence "\x98\x8c" from SHIFT_JIS to UTF-8, iconv correctly returns -1 and sets errno to EILSEQ, however it advances input pointers, consuming the ill sequence.  It should not.

This is causing gnome-terminal to crash seeing that sequence at the end of input.  I'm fixing the crasher in g-t, but the real bug is in iconv.  g-t bug:
http://bugzilla.gnome.org/show_bug.cgi?id=567064

Attaching test case.

Comment 1 Jakub Jelinek 2009-04-23 10:22:31 UTC
Testcase is missing...

Comment 2 Jakub Jelinek 2009-04-23 10:32:55 UTC
I've tried:
#include <iconv.h>
#include <assert.h>
#include <errno.h>

int
main (void)
{
  iconv_t i1 = iconv_open ("ISO-8859-1//", "UTF-8//");
  iconv_t i2 = iconv_open ("UTF-8//", "SHIFT-JIS//");
  char *inbuf, *outbuf, buf[64];
  size_t inbytesleft, outbytesleft, res;

  inbuf = "\x83\x83\x83";
  inbytesleft = 3;
  outbuf = buf;
  outbytesleft = 64;
  errno = 0;
  res = iconv (i1, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
  assert (res == (size_t) -1 && errno == EILSEQ && inbytesleft == 3 && outbytesleft == 64);

  inbuf = "\xec\x98\x8c";
  inbytesleft = 3;
  outbuf = buf;
  outbytesleft = 64;
  errno = 0;
  res = iconv (i2, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
  assert (res == (size_t) -1 && errno == EILSEQ && inbytesleft == 3 && outbytesleft == 64);

  return 0;
}

but that works as expected.

Comment 3 Behdad Esfahbod 2009-04-23 22:51:47 UTC
Created attachment 341034 [details]
test case

Sorry.  I'm sure I attached in the original report form...

Anyway, seems to work for "\xec\x98\x8c", but not for "x\x98\x8c".

Comment 4 Jakub Jelinek 2009-04-27 20:11:21 UTC
Should be fixed in glibc-2.9.90-22.

Comment 5 Behdad Esfahbod 2009-04-27 20:21:49 UTC
Thanks.


Note You need to log in before you can comment on or make changes to this bug.