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

sun.net.util.IPAddressUtil.isIPv4LiteralAddress returns "true" for numeric values e.g. "4324"

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_74"
      Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux dsmdmini-mint 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      I tried to use sun.net.util.IPAddressUtil.isIPv4LiteralAddress method for IPv4 validation, but it returned 'true' for some numeric values, e.g. 4324, 543, 5345435, 345435.

      Maybe it is related to https://bugs.openjdk.java.net/browse/JDK-8087190

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the following line of code: sun.net.util.IPAddressUtil.isIPv4LiteralAddress("4324");

      2. Observe, that 'true' is returned.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      'false' should be returned for numeric values without dots
      ACTUAL -
      'true' is returned

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main (String[] args) {
              System.out.printf(((Boolean)IPAddressUtil.isIPv4LiteralAddress("43421")).toString());
          }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I don't have a workaround, other than using some type of regexp and not relying on JDK code.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psonal Pallavi Sonal
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: