-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_8
Here is a small list of Bad IPv4 addresses that java_net.URL class is not catching. I found these while testing the URL.equals() method
A MalformedURLException should be thrown if address is bad.
List:
"129.300.455.976",
"129.144.126",
"129.144.126.",
"129.144.126.29.",
"129.144.126.29.10",
"129.144.-16.10",
"129.0x90.126.29"
Test Program:
import java.net.*;
public class bug {
public static void main(String[] args) {
String bad_addr4[] = {
"129.300.455.976",
"129.144.126",
"129.144.126.",
"129.144.126.29.",
"129.144.126.29.10",
"129.144.-16.10",
"129.0x90.126.29" };
String s[] = bad_addr4;
int i = 0;
while ( i < s.length ) {
try {
URL url = new URL("http://"+s[i]);
System.err.println("Test FAILed:"
+ " URL constructor did not throw exception.");
} catch (MalformedURLException e) {
System.out.println("Test PASSed: URL constructor threw exception.");
System.out.println(e.getMessage());
}
i++;
}
}
}
java bug
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
gary.collins@East 2000-04-06
A MalformedURLException should be thrown if address is bad.
List:
"129.300.455.976",
"129.144.126",
"129.144.126.",
"129.144.126.29.",
"129.144.126.29.10",
"129.144.-16.10",
"129.0x90.126.29"
Test Program:
import java.net.*;
public class bug {
public static void main(String[] args) {
String bad_addr4[] = {
"129.300.455.976",
"129.144.126",
"129.144.126.",
"129.144.126.29.",
"129.144.126.29.10",
"129.144.-16.10",
"129.0x90.126.29" };
String s[] = bad_addr4;
int i = 0;
while ( i < s.length ) {
try {
URL url = new URL("http://"+s[i]);
System.err.println("Test FAILed:"
+ " URL constructor did not throw exception.");
} catch (MalformedURLException e) {
System.out.println("Test PASSed: URL constructor threw exception.");
System.out.println(e.getMessage());
}
i++;
}
}
}
java bug
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
Test FAILed: URL constructor did not throw exception.
gary.collins@East 2000-04-06