Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4328428

URL classes not throwing MalformedURLException for Bad IPv4 addresses

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            ksrini Kumar Srinivasan
            Reporter:
            collins Gary Collins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: