This is an automated email from the ASF dual-hosted git repository. JackieTien97 pushed a commit to branch ty/TElasticFramedTransport in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 896f8b554785195492b09a2e060d90bd1fdbe6fc Author: JackieTien97 <[email protected]> AuthorDate: Thu May 7 10:25:13 2026 +0800 Refuse unreasonable string length in thrift frame --- .../org/apache/iotdb/rpc/TElasticFramedTransport.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 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..3f2b6970430 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,7 +233,7 @@ 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) ? String.format(messageFormat, size, maxSize, remoteInfo) @@ -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
