-
Bug
-
Resolution: Fixed
-
P3
-
1.1.4
-
1.2beta3
-
sparc
-
solaris_2.5
-
Verified
Name: yyC67448 Date: 11/11/97
The java.net.DatagramPacket.setLength(int length) method does not check
length for negative values.
Here is the test demonstrating the bug:
-------------------------------- Test.java -----------------------------
import java.net.*;
class test
{
public static void main(String args[])
{
DatagramPacket pac = null;
byte[] ar = new byte[10];
int len = -2;
try {
pac = new DatagramPacket(ar, ar.length);
} catch(Exception e)
{
System.out.println("Failed. Can not create DatagramPacket:" + e);
System.exit(-1);
}
try {
pac.setLength(len);
} catch(IllegalArgumentException e)
{
System.out.println("OKAY");
System.exit(0);
}
catch(Exception e)
{
System.out.println("Failed. Unexpected exception:" + e);
System.exit(-1);
}
System.out.println("Failed. No exceptions.");
}
}
---------------------- Output from the test -----------------
Failed. No exceptions.
-----------------------------------------------------------------
======================================================================