You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2024/12/27 06:56:20 UTC
(iotdb) branch detect_singular_frame_size_13 created (now b5d2041efa6)
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a change to branch detect_singular_frame_size_13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at b5d2041efa6 spotless
This branch includes the following new commits:
new b643c7f0948 Detect singular frame length in TElasticFramedTransport
new b5d2041efa6 spotless
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 02/02: spotless
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch detect_singular_frame_size_13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b5d2041efa6a2e019ad9633ed1afb2455522e835
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Dec 27 14:56:05 2024 +0800
spotless
---
.../apache/iotdb/rpc/TElasticFramedTransport.java | 7 +++--
.../iotdb/rpc/TElasticFramedTransportTest.java | 33 ++++++++++++++--------
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
index b77ef614311..4c7602c8699 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
@@ -132,8 +132,11 @@ public class TElasticFramedTransport extends TTransport {
close();
if (size == 1195725856L || size == 1347375956L) {
// if someone sends HTTP GET/POST to this port, the size will be read as the following
- throw new TTransportException(TTransportException.CORRUPTED_DATA,
- "Singular frame size (" + size + ") detected, you may be sending HTTP GET/POST requests to the Thrift-RPC port, please confirm that you are using the right port");
+ throw new TTransportException(
+ TTransportException.CORRUPTED_DATA,
+ "Singular frame size ("
+ + size
+ + ") detected, you may be sending HTTP GET/POST requests to the Thrift-RPC port, please confirm that you are using the right port");
} else {
throw new TTransportException(
TTransportException.CORRUPTED_DATA,
diff --git a/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java b/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java
index f497ad6f38a..086dc338250 100644
--- a/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java
+++ b/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java
@@ -19,24 +19,29 @@
package org.apache.iotdb.rpc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
import org.apache.thrift.transport.TByteBuffer;
import org.apache.thrift.transport.TTransportException;
import org.junit.Test;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
public class TElasticFramedTransportTest {
@Test
public void testSingularSize() {
try {
- TElasticFramedTransport transport = new TElasticFramedTransport(
- new TByteBuffer(ByteBuffer.wrap("GET 127.0.0.1 HTTP/1.1".getBytes(
- StandardCharsets.UTF_8))), 128 * 1024 * 1024, 512 * 1024 * 1024, false);
+ TElasticFramedTransport transport =
+ new TElasticFramedTransport(
+ new TByteBuffer(
+ ByteBuffer.wrap("GET 127.0.0.1 HTTP/1.1".getBytes(StandardCharsets.UTF_8))),
+ 128 * 1024 * 1024,
+ 512 * 1024 * 1024,
+ false);
transport.open();
transport.read(ByteBuffer.allocate(4096));
fail("Exception expected");
@@ -47,9 +52,13 @@ public class TElasticFramedTransportTest {
}
try {
- TElasticFramedTransport transport = new TElasticFramedTransport(
- new TByteBuffer(ByteBuffer.wrap("POST 127.0.0.1 HTTP/1.1".getBytes(
- StandardCharsets.UTF_8))), 128 * 1024 * 1024, 512 * 1024 * 1024, false);
+ TElasticFramedTransport transport =
+ new TElasticFramedTransport(
+ new TByteBuffer(
+ ByteBuffer.wrap("POST 127.0.0.1 HTTP/1.1".getBytes(StandardCharsets.UTF_8))),
+ 128 * 1024 * 1024,
+ 512 * 1024 * 1024,
+ false);
transport.open();
transport.read(ByteBuffer.allocate(4096));
fail("Exception expected");
@@ -59,4 +68,4 @@ public class TElasticFramedTransportTest {
e.getMessage());
}
}
-}
\ No newline at end of file
+}
(iotdb) 01/02: Detect singular frame length in TElasticFramedTransport
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch detect_singular_frame_size_13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b643c7f0948ce7104773b12a6fab88f7b19517b5
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Dec 27 14:53:18 2024 +0800
Detect singular frame length in TElasticFramedTransport
(cherry picked from commit 06b8651c5c6e4ba63a8f5f88a4c98799fb7835df)
---
.../apache/iotdb/rpc/TElasticFramedTransport.java | 12 +++--
.../iotdb/rpc/TElasticFramedTransportTest.java | 62 ++++++++++++++++++++++
2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
index b0c55c21bd0..b77ef614311 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java
@@ -130,9 +130,15 @@ public class TElasticFramedTransport extends TTransport {
if (size > thriftMaxFrameSize) {
close();
- throw new TTransportException(
- TTransportException.CORRUPTED_DATA,
- "Frame size (" + size + ") larger than protect max size (" + thriftMaxFrameSize + ")!");
+ if (size == 1195725856L || size == 1347375956L) {
+ // if someone sends HTTP GET/POST to this port, the size will be read as the following
+ throw new TTransportException(TTransportException.CORRUPTED_DATA,
+ "Singular frame size (" + size + ") detected, you may be sending HTTP GET/POST requests to the Thrift-RPC port, please confirm that you are using the right port");
+ } else {
+ throw new TTransportException(
+ TTransportException.CORRUPTED_DATA,
+ "Frame size (" + size + ") larger than protect max size (" + thriftMaxFrameSize + ")!");
+ }
}
readBuffer.fill(underlying, size);
}
diff --git a/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java b/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java
new file mode 100644
index 00000000000..f497ad6f38a
--- /dev/null
+++ b/iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TElasticFramedTransportTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.rpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import org.apache.thrift.transport.TByteBuffer;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Test;
+
+public class TElasticFramedTransportTest {
+
+ @Test
+ public void testSingularSize() {
+
+ try {
+ TElasticFramedTransport transport = new TElasticFramedTransport(
+ new TByteBuffer(ByteBuffer.wrap("GET 127.0.0.1 HTTP/1.1".getBytes(
+ StandardCharsets.UTF_8))), 128 * 1024 * 1024, 512 * 1024 * 1024, false);
+ transport.open();
+ transport.read(ByteBuffer.allocate(4096));
+ fail("Exception expected");
+ } catch (TTransportException e) {
+ assertEquals(
+ "Singular frame size (1195725856) detected, you may be sending HTTP GET/POST requests to the Thrift-RPC port, please confirm that you are using the right port",
+ e.getMessage());
+ }
+
+ try {
+ TElasticFramedTransport transport = new TElasticFramedTransport(
+ new TByteBuffer(ByteBuffer.wrap("POST 127.0.0.1 HTTP/1.1".getBytes(
+ StandardCharsets.UTF_8))), 128 * 1024 * 1024, 512 * 1024 * 1024, false);
+ transport.open();
+ transport.read(ByteBuffer.allocate(4096));
+ fail("Exception expected");
+ } catch (TTransportException e) {
+ assertEquals(
+ "Singular frame size (1347375956) detected, you may be sending HTTP GET/POST requests to the Thrift-RPC port, please confirm that you are using the right port",
+ e.getMessage());
+ }
+ }
+}
\ No newline at end of file