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

The java.net.URL constructor allows port < 0 and port > 65535

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: yyC67448 Date: 12/29/97



      The java.net.URL constructor does not check whether the port value is negative
      or greater than 65535 for http and ftp url's.


      Here is the test demonstrating the bug:

      ------------------------ Test.java ---------------------------------------
      import java.net.*;

      public class Test
      {
       public static void main(String argv[])
       {
         URL url[4];
         String host = "web2.javasoft.com";
         String file = "/index.html";
         int port = -20;
         int port1 = 65536;


         try {
           url[0] = new URL("ftp", host, port, file);
           url[1] = new URL("http", host, port, file);
           url[2] = new URL("ftp", host, port1, file);
           url[3] = new URL("http", host, port1, file);
         } catch(MalformedURLException e)
         {
             System.out.println("Passed. OKAY");
             System.exit(0);
         }
         catch(Exception e)
         {
           System.out.println("Unexpected exception:" + e);
           System.exit(-1);
         }
         
         System.out.println("No exceptions");
         System.exit(-1);

       }
         
      }
      ------------------------- Output from the test ----------------------------
      No exceptions
      ---------------------------------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              jccollet Jean-Christophe Collet (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: