添加一些异常数据的处理

This commit is contained in:
heavyrian2012
2023-03-20 13:49:29 +08:00
parent 11b7851b9f
commit 68abeed907
2 changed files with 10 additions and 2 deletions
@@ -608,8 +608,9 @@ public class ProtocolProcessor {
channel.closeFuture();
//disconnect the session
m_sessionsStore.sessionForClient(clientID).disconnect(session.getUsername(), isDup, isRetain);
if(session != null) {
m_sessionsStore.sessionForClient(clientID).disconnect(session.getUsername(), isDup, isRetain);
}
}
@@ -252,6 +252,13 @@ public class Qos1PublishHandler extends QosPublishHandler {
MemorySessionStore.Session session = m_sessionStore.getSession(clientID);
payloadContent = AES.AESDecrypt(payloadContent, session.getSecret(), true);
if(payloadContent == null) {
ByteBuf ackPayload = Unpooled.buffer();
ackPayload.ensureWritable(1).writeByte(ERROR_CODE_INVALID_DATA.getCode());
sendPubAck(clientID, messageID, ackPayload, ERROR_CODE_INVALID_DATA);
return;
}
imHandler(clientID, username, imtopic, payloadContent, (errorCode, ackPayload) -> sendPubAck(clientID, messageID, ackPayload, errorCode), ProtoConstants.RequestSourceType.Request_From_User);
}