-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b94
-
sparc
-
solaris_2.5.1
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8038324 | 6u81 | Ivan Gerasimov | P3 | Resolved | Fixed | b02 |
This is observed in Java 5 and Java 6.
When called with -Djava.net.preferIPv6Addresses=true the call to DatagramSocket getLocalSocketAddress returns an all-zero address, instead of ::1.
InetAddress iNet = InetAddress.getByName("localhost");
DatagramSocket soc = new DatagramSocket( 12345, iNet);
SocketAddress sa = soc. getLocalSocketAddress();
System.out.println("iNet: " + iNet);
System.out.println("Expected: " + iNet + ":12345");
System.out.println("Returned: " + ((InetSocketAddress)sa).getAddress());
workaround: Here's a fix:
In net_util_md.h, the macro IN6_IS_ADDR_ANY is defined as:
#define IN6_IS_ADDR_ANY(a) \
(((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \
((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \
((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0))
It should be:
#define IN6_IS_ADDR_ANY(a) \
(((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \
((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \
((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0) && \
((a)->s6_words[6] == 0) && ((a)->s6_words[7] == 0))
IPV6 addresses are 16 bytes long, the macros only tests 12 bytes.
When called with -Djava.net.preferIPv6Addresses=true the call to DatagramSocket getLocalSocketAddress returns an all-zero address, instead of ::1.
InetAddress iNet = InetAddress.getByName("localhost");
DatagramSocket soc = new DatagramSocket( 12345, iNet);
SocketAddress sa = soc. getLocalSocketAddress();
System.out.println("iNet: " + iNet);
System.out.println("Expected: " + iNet + ":12345");
System.out.println("Returned: " + ((InetSocketAddress)sa).getAddress());
workaround: Here's a fix:
In net_util_md.h, the macro IN6_IS_ADDR_ANY is defined as:
#define IN6_IS_ADDR_ANY(a) \
(((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \
((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \
((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0))
It should be:
#define IN6_IS_ADDR_ANY(a) \
(((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \
((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \
((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0) && \
((a)->s6_words[6] == 0) && ((a)->s6_words[7] == 0))
IPV6 addresses are 16 bytes long, the macros only tests 12 bytes.
- backported by
-
JDK-8038324 IN6_IS_ADDR_ANY tests only 12 bytes of 16-byte address
- Resolved