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

NetworkInterface.getNetworkInterfaces() may return corrupted results on linux

XMLWordPrintable

    • b21
    • x86
    • linux
    • Verified

        FULL PRODUCT VERSION :
        OpenJDK Runtime Environment (IcedTea6 1.8.7) (6b18-1.8.7-2~squeeze1)
        OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Linux l-at9676 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        calling NetworkInterface.getNetworkInterfaces() on linux returns corrupted results if some interface's index is over 255 (which is sometimes the case for virtual interfaces).

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. call NetworkInterface.getNetworkInterfaces() on a machine where some IPv6 enabled interface's index is over 255 (larger than 2 hex-digits)

        to check : call "cat /proc/net/if_inet6" in a shell. If any of the number in the second column is over 2 hex-digits, the bug will occur. Example:

        00000000000000000000000000000001 01 80 10 80 lo
        fe80000000000000f8b164fffe2eaa8e 17f 40 20 80 veth0sACuM
        fe80000000000000021517fffee3ae55 04 40 20 80 eth0

        2. browse the resulting enumeration : in contains corrupted NetworkInterface objects which doen't correspond to any interface on the machine. Calling methods such as isUp() or isVirtual() on these objects will throw a SocketException

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        a list of existing NetworkInterface object
        ACTUAL -
        a list containing some existing NetworkInterface mixed with corrupted, non existing NetworkInterface objects

        REPRODUCIBILITY :
        This bug can be reproduced always.

        CUSTOMER SUBMITTED WORKAROUND :
        the bug is caused by an incorrect format string in the C fscanf function, in /openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c , [line 1108 in openjdk-7-fcs-src-b147-27_jun_2011.zip]

        the format string is
        "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n"
        ans shoud be
        "%4s%4s%4s%4s%4s%4s%4s%4s %03x %02x %02x %02x %20s\n"
        to be able to parse entries withe a second colum larger than 2 hex-digits.

        modifying this line solved the problem for me.

              bpassani Brandon Passanisi
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: