Bug 497267 - Bug in SHIFT_JIS EILSEQ handling
Bug in SHIFT_JIS EILSEQ handling
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-23 01:18 EDT by Behdad Esfahbod
Modified: 2009-04-27 16:21 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-04-27 16:11:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Behdad Esfahbod 2009-04-23 01:18:29 EDT
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 06:22:31 EDT
Testcase is missing...
Comment 2 Jakub Jelinek 2009-04-23 06:32:55 EDT
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 18:51:47 EDT
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 16:11:21 EDT
Should be fixed in glibc-2.9.90-22.
Comment 5 Behdad Esfahbod 2009-04-27 16:21:49 EDT
Thanks.

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