JDK-4429369 : ISO2022CN and ISO2022KR converters throw exception in response to illegal escape
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-03-23
  • Updated: 2001-07-13
  • Resolved: 2001-07-13
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
1.4.0 beta2Fixed
Related Reports
Relates :  
Description
The ISO2022CN and ISO2022KR converters do not handle invalid escape sequences correctly. They throw an ArrayIndexOutOfBoundsException when illegal/malformed
escapes are encountered within an input stream.  Note: This is one of a number
of bugs resulting from a distillation of BugID 4296969, Incorrect behaviour of
several character converters. 

The following test case will demonstrate this behaviour:

/*
 * Runtime exceptions generated when illegal ISO2022 escapes
 * are provided within an input stream to be decoded
 */

public class InvalidEscapes {
 
  public static void main(String[] args){

        for (int i = 0; i < encodings.length; i++){
            test(encodings[i]);
        }

        try {
            byte[] bb = new byte[] {(byte)0x1b, (byte)')',  (byte)'x'};
            String str = new String(bb,"ISO2022CN");
        } catch (Throwable th){
            System.err.println("ISO2022CN error " + th);
        }

        try {
            byte[] bb = new byte[] {(byte)0x1b, (byte)')',  (byte)'x'};
            String str = new String(bb,"ISO2022KR");
        } catch (Throwable th){
            System.err.println("ISO2022KR error " + th);
        }

    }
 }

Ian.Little@Irleland 3/23/2001.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
14-06-2004

EVALUATION The code which reads ahead when an ISO2022 escape ( 0x1b) is encountered doesn't peform sufficient bounds checks. It should and it should determine if the subsequent characters are part of a legal ISO2022-XX escaped designation sequence. Otherwise it should throw a MalformedInputException. Both ISO2022CN and ISO2022KR share the same read-ahead method with the same inadequate bounds check and without the required legal escape sequence hecking logic. Ian.Little@Ireland 6/25/2001
25-06-2001