Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-05-19 14:09:57 -0400
committereutarass2010-05-19 14:09:57 -0400
commiteaec0ce3852eab960d9ac864fb6223783784b9a1 (patch)
tree7a7f6c5704695242f5f1001c8296bbfabfe3c56f /plugins
parent0b33020ffc60af42af98b7d7a2c6cea67c509801 (diff)
downloadorg.eclipse.tcf-eaec0ce3852eab960d9ac864fb6223783784b9a1.tar.gz
org.eclipse.tcf-eaec0ce3852eab960d9ac864fb6223783784b9a1.tar.xz
org.eclipse.tcf-eaec0ce3852eab960d9ac864fb6223783784b9a1.zip
Bug 312457: Exception in LocatorService.Subnet.contains
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java
index 909116ee7..7e8f02550 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java
@@ -13,6 +13,7 @@ package org.eclipse.tm.internal.tcf.services.local;
import java.lang.reflect.Method;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
+import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
@@ -85,12 +86,13 @@ public class LocatorService implements ILocator {
byte[] a2 = address.getAddress();
if (a1.length != a2.length) return false;
int i = 0;
- while (i + 8 <= prefix_length) {
+ int l = prefix_length <= a1.length * 8 ? prefix_length : a1.length * 8;
+ while (i + 8 <= l) {
int n = i / 8;
if (a1[n] != a2[n]) return false;
i += 8;
}
- while (i < prefix_length) {
+ while (i < l) {
int n = i / 8;
int m = 1 << (7 - i % 8);
if ((a1[n] & m) != (a2[n] & m)) return false;
@@ -514,6 +516,19 @@ public class LocatorService implements ILocator {
}
}
+ if (address instanceof Inet4Address && network_prefix_len > 32) {
+ /*
+ * Workaround for JVM bug:
+ * InterfaceAddress.getNetworkPrefixLength() does not conform to Javadoc
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6707289
+ *
+ * The bug shows up only when IPv6 is enabled.
+ * The bug is supposed to be fixed in Java 1.7.
+ */
+ // TODO: need a better way to get network prefix length on Java 1.6 VM
+ network_prefix_len = 24;
+ }
+
// TODO: discovery over IPv6
/* Create IPv6 broadcast address.

Back to the top