This is an automated email from the ASF dual-hosted git repository.

JackieTien97 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new f5fbaa2a3c9 Refuse unreasonable string length in thrift frame (#17612)
f5fbaa2a3c9 is described below

commit f5fbaa2a3c9da6743a06e07fa680fe3714a89b14
Author: Jackie Tien <[email protected]>
AuthorDate: Thu May 7 15:24:05 2026 +0800

    Refuse unreasonable string length in thrift frame (#17612)
---
 .../org/apache/iotdb/rpc/TElasticFramedTransport.java  | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 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 955fdd01a9e..69ac5fbb56f 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
@@ -224,7 +224,8 @@ public class TElasticFramedTransport extends TTransport {
             + "requests%s to the Non-SSL Thrift-RPC port, please confirm that 
you are using "
             + "the right configuration"),
     NEGATIVE_FRAME_SIZE("Read a negative frame size (%d)%s!"),
-    FRAME_SIZE_EXCEEDED("Frame size (%d) larger than protect max size 
(%d)%s!");
+    FRAME_SIZE_EXCEEDED("Frame size (%d) larger than protect max size 
(%d)%s!"),
+    STRING_LENGTH_EXCEEDED("String length (%d) larger than protect max size 
(%d)%s!");
 
     private final String messageFormat;
 
@@ -232,9 +233,9 @@ public class TElasticFramedTransport extends TTransport {
       this.messageFormat = messageFormat;
     }
 
-    void throwException(int size, String remoteInfo, int maxSize) throws 
TTransportException {
+    void throwException(long size, String remoteInfo, int maxSize) throws 
TTransportException {
       String message =
-          (this == FRAME_SIZE_EXCEEDED)
+          (this == FRAME_SIZE_EXCEEDED || this == STRING_LENGTH_EXCEEDED)
               ? String.format(messageFormat, size, maxSize, remoteInfo)
               : String.format(messageFormat, size, remoteInfo);
       throw new TTransportException(TTransportException.CORRUPTED_DATA, 
message);
@@ -283,8 +284,15 @@ public class TElasticFramedTransport extends TTransport {
 
   @Override
   public void checkReadBytesAvailable(long numBytes) throws 
TTransportException {
-    // do nothing now.
-    // here we can do some checkm, e.g., see whether the memory is enough.
+    if (numBytes >= thriftMaxFrameSize) {
+      SocketAddress remoteAddress = null;
+      if (underlying instanceof TSocket) {
+        remoteAddress = ((TSocket) 
underlying).getSocket().getRemoteSocketAddress();
+      }
+      String remoteInfo = (remoteAddress == null) ? "" : " from " + 
remoteAddress;
+      close();
+      FrameError.STRING_LENGTH_EXCEEDED.throwException(numBytes, remoteInfo, 
thriftMaxFrameSize);
+    }
   }
 
   @Override

Reply via email to