-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: saC57035 Date: 01/21/98
The java.io.PipedInputStream read(byte b[], int off, int len) may not throw
IndexOutOfBoundsException in case of off or len out of bounds. That is caused
by overflow which occurs when off + len exceed Integer.MAX_VALUE.
Actually this bug is a follow up for bugs 1266817 and 1266818. They were fixed
in 1.1, however the fix happened to be incomplete.
This bug causes the following JCK test to fail:
api/java_io/PipedInputStream/manual.html#Read
Below is the test demonstrating the bug:
----------- ClassTest.java--------------------
import java.io.*;
public class Test5 {
public static void main( String[] argv ) {
PipedOutputStream os = new PipedOutputStream();
PipedInputStream is = new PipedInputStream();
try {
is.connect(os);
} catch(Throwable e) {
System.out.println("Test failed: unexpected <"+e+"> thrown");
}
byte[] b = new byte[10];
try {
os.write(101);
os.close();
is.read(b,1,Integer.MAX_VALUE);
System.out.println("Test failed: IndexOutOfBoundsException expected");
} catch(IndexOutOfBoundsException e) {
try {
int a = is.read();
if (a==101)
System.out.println("Test passed: IndexOutOfBoundsException thrown");
else
System.out.println("Test failed: unexpected reading performed");
} catch(IOException e1) {
System.out.println("Test failed: unexpected <"+e1+"> thrown");
}
} catch(Throwable e) {
System.out.println("Test failed: unexpected <"+e+"> thrown");
}
}
}
------ Output of the test --------
Test failed: IndexOutOfBoundsException expected
======================================================================
- duplicates
-
JDK-4008296 java.io.XXXXInputStream.read(b,off,len) methods work wrong with off, len
-
- Closed
-
- relates to
-
JDK-4008293 java.io.XXXXInputStream.read(b,off,len) methods work wrong with b
-
- Closed
-