Repository: cassandra Updated Branches: refs/heads/trunk 9d05efafe -> 4dd1a15cc
Validate IPv6 wildcard addresses properly patch by Robert Stupp; reviewed by Aleksey Yeschenko for CASSANDRA-7680 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/04a1fc6e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/04a1fc6e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/04a1fc6e Branch: refs/heads/trunk Commit: 04a1fc6e10ba6ffd774c3d5a67a650520a0ac896 Parents: ffb919e Author: Robert Stupp <[email protected]> Authored: Fri Aug 15 03:59:29 2014 +0300 Committer: Aleksey Yeschenko <[email protected]> Committed: Fri Aug 15 03:59:29 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/config/DatabaseDescriptor.java | 37 +++++++------------- 2 files changed, 14 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/04a1fc6e/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 99fb988..ea9e8aa 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.1 + * Validate IPv6 wildcard addresses properly (CASSANDRA-7680) * (cqlsh) Error when tracing query (CASSANDRA-7613) * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569) * SSTableExport uses correct validator to create string representation of partition http://git-wip-us.apache.org/repos/asf/cassandra/blob/04a1fc6e/src/java/org/apache/cassandra/config/DatabaseDescriptor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index f624ce5..e8c5372 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -298,8 +298,6 @@ public class DatabaseDescriptor } else if (conf.listen_address != null) { - if (conf.listen_address.equals("0.0.0.0")) - throw new ConfigurationException("listen_address cannot be 0.0.0.0!"); try { listenAddress = InetAddress.getByName(conf.listen_address); @@ -308,6 +306,9 @@ public class DatabaseDescriptor { throw new ConfigurationException("Unknown listen_address '" + conf.listen_address + "'"); } + + if (listenAddress.isAnyLocalAddress()) + throw new ConfigurationException("listen_address cannot be a wildcard address (" + conf.listen_address + ")!"); } else if (conf.listen_interface != null) { @@ -328,11 +329,6 @@ public class DatabaseDescriptor /* Gossip Address to broadcast */ if (conf.broadcast_address != null) { - if (conf.broadcast_address.equals("0.0.0.0")) - { - throw new ConfigurationException("broadcast_address cannot be 0.0.0.0!"); - } - try { broadcastAddress = InetAddress.getByName(conf.broadcast_address); @@ -341,6 +337,9 @@ public class DatabaseDescriptor { throw new ConfigurationException("Unknown broadcast_address '" + conf.broadcast_address + "'"); } + + if (broadcastAddress.isAnyLocalAddress()) + throw new ConfigurationException("broadcast_address cannot be a wildcard address (" + conf.broadcast_address + ")!"); } /* Local IP, hostname or interface to bind RPC server to */ @@ -381,33 +380,23 @@ public class DatabaseDescriptor /* RPC address to broadcast */ if (conf.broadcast_rpc_address != null) { - if (conf.broadcast_rpc_address.equals("0.0.0.0")) - throw new ConfigurationException("broadcast_rpc_address cannot be 0.0.0.0"); - try { broadcastRpcAddress = InetAddress.getByName(conf.broadcast_rpc_address); } catch (UnknownHostException e) { - throw new ConfigurationException("Unkown broadcast_rpc_address '" + conf.broadcast_rpc_address + "'"); + throw new ConfigurationException("Unknown broadcast_rpc_address '" + conf.broadcast_rpc_address + "'"); } + + if (broadcastRpcAddress.isAnyLocalAddress()) + throw new ConfigurationException("broadcast_rpc_address cannot be a wildcard address (" + conf.broadcast_rpc_address + ")!"); } else { - InetAddress bindAll; - try - { - bindAll = InetAddress.getByAddress(new byte[4]); - } - catch (UnknownHostException e) - { - throw new RuntimeException("Host 0.0.0.0 is somehow unknown"); - } - - if (rpcAddress.equals(bindAll)) - throw new ConfigurationException("If rpc_address is set to 0.0.0.0, you must set broadcast_rpc_address " + - "to a value other than 0.0.0.0"); + if (rpcAddress.isAnyLocalAddress()) + throw new ConfigurationException("If rpc_address is set to a wildcard address (" + conf.rpc_address + "), then " + + "you must set broadcast_rpc_address to a value other than " + conf.rpc_address); broadcastRpcAddress = rpcAddress; }
