fix: add the determination of whether ssl is enabled

when the buffer is always full but no new data has been read, an error needs to be reported
This commit is contained in:
guoaomen
2022-11-30 14:05:08 +08:00
parent 5231b4493e
commit 711e756c98
2 changed files with 7 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package com.actiontech.dble.backend.mysql.proto.handler.Impl;
import com.actiontech.dble.backend.mysql.proto.handler.ProtoHandler;
import com.actiontech.dble.backend.mysql.proto.handler.ProtoHandlerResult;
import com.actiontech.dble.config.model.SystemConfig;
import com.actiontech.dble.net.mysql.MySQLPacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,7 +80,7 @@ public class MySQLProtoHandlerImpl implements ProtoHandler {
// not read whole message package ,so check if buffer enough and
// compact dataBuffer
if (!dataBuffer.hasRemaining()) {
if (SSLProtoHandler.isSSLPackage(dataBuffer, offset)) {
if (SystemConfig.getInstance().isSupportSSL() && SSLProtoHandler.isSSLPackage(dataBuffer, offset)) {
return builder.setCode(SSL_PROTO_PACKET).setHasMorePacket(false).setOffset(offset);
}
return builder.setCode(BUFFER_NOT_BIG_ENOUGH).setHasMorePacket(false).setOffset(offset).setPacketLength(length);

View File

@@ -109,8 +109,13 @@ public abstract class AbstractConnection implements Connection {
} else {
netInBytes += got;
}
final ByteBuffer tmpReadBuffer = getReadBuffer();
if (tmpReadBuffer != null) {
if (got == 0 && tmpReadBuffer.position() != 0 && tmpReadBuffer.position() == tmpReadBuffer.limit()) {
//The buffer is full, but has not been read
throw new IllegalStateException("there is a problem with buffer reading");
}
handle(tmpReadBuffer);
} else if (!isClosed()) {
//generally,it's won't happen