You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2021/10/09 06:01:31 UTC
[cassandra] branch trunk updated: Skip remaining bytes in the
Envelope buffer when a ProtocolException is thrown to avoid double decoding
This is an automated email from the ASF dual-hosted git repository.
maedhroz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 4f09733 Skip remaining bytes in the Envelope buffer when a ProtocolException is thrown to avoid double decoding
4f09733 is described below
commit 4f09733d28398207bc16ace92cda6e1ffeb99644
Author: Caleb Rackliffe <ca...@gmail.com>
AuthorDate: Thu Oct 7 13:34:26 2021 -0500
Skip remaining bytes in the Envelope buffer when a ProtocolException is thrown to avoid double decoding
patch by Caleb Rackliffe; reviewed by Sam Tunnicliffe and Jon Meredith for CASSANDRA-17026
---
CHANGES.txt | 1 +
src/java/org/apache/cassandra/transport/Envelope.java | 14 +++++++++++++-
.../UnableToParseClientMessageFromBlockedSubnetTest.java | 2 +-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index efcbb5d..8e06776 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.1
+ * Skip remaining bytes in the Envelope buffer when a ProtocolException is thrown to avoid double decoding (CASSANDRA-17026)
* Allow reverse iteration of resources during permissions checking (CASSANDRA-17016)
* Add feature to verify correct ownership of attached locations on disk at startup (CASSANDRA-16879)
* Make SSLContext creation pluggable/extensible (CASSANDRA-16666)
diff --git a/src/java/org/apache/cassandra/transport/Envelope.java b/src/java/org/apache/cassandra/transport/Envelope.java
index 6b15a2a..99c6e13 100644
--- a/src/java/org/apache/cassandra/transport/Envelope.java
+++ b/src/java/org/apache/cassandra/transport/Envelope.java
@@ -353,7 +353,19 @@ public class Envelope
int firstByte = buffer.getByte(idx++);
Message.Direction direction = Message.Direction.extractFromVersion(firstByte);
int versionNum = firstByte & PROTOCOL_VERSION_MASK;
- ProtocolVersion version = ProtocolVersion.decode(versionNum, DatabaseDescriptor.getNativeTransportAllowOlderProtocols());
+
+ ProtocolVersion version;
+
+ try
+ {
+ version = ProtocolVersion.decode(versionNum, DatabaseDescriptor.getNativeTransportAllowOlderProtocols());
+ }
+ catch (ProtocolException e)
+ {
+ // Skip the remaining useless bytes. Otherwise the channel closing logic may try to decode again.
+ buffer.skipBytes(readableBytes);
+ throw e;
+ }
// Wait until we have the complete header
if (readableBytes < Header.LENGTH)
diff --git a/test/distributed/org/apache/cassandra/distributed/test/UnableToParseClientMessageFromBlockedSubnetTest.java b/test/distributed/org/apache/cassandra/distributed/test/UnableToParseClientMessageFromBlockedSubnetTest.java
index 2647ba7..27dcd2c 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/UnableToParseClientMessageFromBlockedSubnetTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/UnableToParseClientMessageFromBlockedSubnetTest.java
@@ -38,7 +38,6 @@ import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.IInvokableInstance;
import org.apache.cassandra.distributed.api.LogAction;
-import org.apache.cassandra.distributed.api.LogResult;
import org.apache.cassandra.transport.Message;
import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.transport.SimpleClient;
@@ -51,6 +50,7 @@ public class UnableToParseClientMessageFromBlockedSubnetTest extends TestBaseImp
private static Cluster CLUSTER;
private static List<String> CLUSTER_EXCLUDED_SUBNETS;
+ @SuppressWarnings("DefaultAnnotationParam")
@Parameterized.Parameter(0)
public List<String> excludeSubnets;
@Parameterized.Parameter(1)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org