JDK-4117820 : ByteToCharSJIS throws ArrayIndexOutofBoundsExceptions
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.1,1.1.6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.5,windows_95
  • CPU: generic,x86
  • Submitted: 1998-03-07
  • Updated: 1999-11-22
  • Resolved: 1998-04-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.1.6_005 005Fixed 1.2.0Fixed
Related Reports
Relates :  
Description
The ByteToCharSJIS converter throws ArrayIndexOutOfBoundsExceptions on input in the range 0xA040 - 0xA0FC.

The stack trace is as follows:

java.lang.ArrayIndexOutOfBoundsException: -33
        at sun.io.ByteToCharDoubleByte.getUnicode(ByteToCharDoubleByte.java:170)
        at sun.io.ByteToCharSJIS.getUnicode(ByteToCharSJIS.java:49)
        at sun.io.ByteToCharDoubleByte.convert(ByteToCharDoubleByte.java:123)
        at DumpByteToChar.DumpMapping(DumpByteToChar.java:161)
        at DumpByteToChar.DumpDoubleByte(DumpByteToChar.java:143)
        at DumpByteToChar.main(DumpByteToChar.java:18)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta4 FIXED IN: 1.1.6_005 1.2beta4 INTEGRATED IN: 1.1.6_005 1.2beta4
14-06-2004

EVALUATION The SJIS to JIS conversion algorithm from Ken Lunde's book, pg 164, is used in the ByteToCharSJIS.geUnicode method. Unfortunately, this algorithm doesn't deal well with invalid input. brian.beck@Eng 1998-03-06 There are a couple of ways to go to fix this bug. Brian's right that Lunde's algorithm assumes legal values. So, a possible fix would be to enhance ByteToCharSJIS.getUnicode() to check the values more carefully. But, on closer inspection, the failure to throw the right exception (MalformedInputException UnknownCharacterException, or UnsupportedCharacterException, depending on whether you believe the comments or the implementation) for illegal codepoints can be traced to sun.io.ByteToCharDoubleByte.getUnicode(). This method does some range checking on the second byte, but not on the first. So, the fix currently being tested is to check that the first byte (which is used as an index into the index1 array) is also a legal value. mark.son-bell@eng 1998-04-13 Fix integrated into jdk1.2beta4 M2 integration workspace. mark.son-bell@eng 1998-04-24
13-04-1998