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

InetAddress.getHostByName allows bad IP addresses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • core-libs
    • beta
    • x86
    • windows_nt



      Name: rlT66838 Date: 03/13/2000


      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      InetAddress.getByName doesn't throw UnknownHostException when it should. For
      example, it happily accepts "999.999.999.999" as a valid IP address, although
      it appears to store each byte modulo 256, in this case 231.231.231.231. The
      following code can be used to verify this behavior.


      import java.net.*;
      import java.io.*;

      public class InetTest
      {
        public static void main (String[] args)
        {
          try {
            InetAddress ip = InetAddress.getByName (args[0]);
            System.out.println ("IP address = " + ip.getHostAddress());
          }
          catch (UnknownHostException e) {
            System.out.println ("Bad IP address");
          }
        }
      }
      (Review ID: 102411)
      ======================================================================

            alanb Alan Bateman
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: