cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/3] git commit: Properly handle unrecognized opcodes and flags
Date Fri, 27 Jun 2014 14:31:34 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 39bdd3b08 -> 72cefc182


Properly handle unrecognized opcodes and flags

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-7440


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e3242315
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e3242315
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e3242315

Branch: refs/heads/trunk
Commit: e32423159d9b31131cc95bccfcfa6b5dabbc070a
Parents: 2b973b9
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Fri Jun 27 09:28:18 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Fri Jun 27 09:28:18 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                          | 1 +
 src/java/org/apache/cassandra/transport/Frame.java   | 7 ++++---
 src/java/org/apache/cassandra/transport/Message.java | 2 ++
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3242315/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 365722f..d587a94 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
  * Fix race in FileCacheService RemovalListener (CASSANDRA-7278)
  * Fix inconsistent use of consistencyForCommit that allowed LOCAL_QUORUM
    operations to incorrect become full QUORUM (CASSANDRA-7345)
+ * Properly handle unrecognized opcodes and flags (CASSANDRA-7440)
 
 
 2.0.9

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3242315/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Frame.java b/src/java/org/apache/cassandra/transport/Frame.java
index 6472b39..89755df 100644
--- a/src/java/org/apache/cassandra/transport/Frame.java
+++ b/src/java/org/apache/cassandra/transport/Frame.java
@@ -92,14 +92,15 @@ public class Frame
             COMPRESSED,
             TRACING;
 
+            private static final Flag[] ALL_VALUES = values();
+
             public static EnumSet<Flag> deserialize(int flags)
             {
                 EnumSet<Flag> set = EnumSet.noneOf(Flag.class);
-                Flag[] values = Flag.values();
-                for (int n = 0; n < 8; n++)
+                for (int n = 0; n < ALL_VALUES.length; n++)
                 {
                     if ((flags & (1 << n)) != 0)
-                        set.add(values[n]);
+                        set.add(ALL_VALUES[n]);
                 }
                 return set;
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e3242315/src/java/org/apache/cassandra/transport/Message.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Message.java b/src/java/org/apache/cassandra/transport/Message.java
index 0731081..eea3b48 100644
--- a/src/java/org/apache/cassandra/transport/Message.java
+++ b/src/java/org/apache/cassandra/transport/Message.java
@@ -103,6 +103,8 @@ public abstract class Message
 
         public static Type fromOpcode(int opcode, Direction direction)
         {
+            if (opcode >= opcodeIdx.length)
+                throw new ProtocolException(String.format("Unknown opcode %d", opcode));
             Type t = opcodeIdx[opcode];
             if (t == null)
                 throw new ProtocolException(String.format("Unknown opcode %d", opcode));


Mime
View raw message