From 476e5927cee5be83361054a643cdba7e77592a12 Mon Sep 17 00:00:00 2001 From: NB Grey <serge.rumyancev@gmail.com> Date: Tue, 31 Dec 2024 21:38:24 +0300 Subject: [PATCH] fix disconnect error when received mqtt version error --- .../davidepianca98/mqtt/packets/mqttv5/MQTT5Connack.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kmqtt-common/src/commonMain/kotlin/io/github/davidepianca98/mqtt/packets/mqttv5/MQTT5Connack.kt b/kmqtt-common/src/commonMain/kotlin/io/github/davidepianca98/mqtt/packets/mqttv5/MQTT5Connack.kt index b27e785..6ee2e81 100644 --- a/kmqtt-common/src/commonMain/kotlin/io/github/davidepianca98/mqtt/packets/mqttv5/MQTT5Connack.kt +++ b/kmqtt-common/src/commonMain/kotlin/io/github/davidepianca98/mqtt/packets/mqttv5/MQTT5Connack.kt @@ -74,6 +74,11 @@ public class MQTT5Connack( ReasonCode.valueOf(inStream.readByte().toInt()) ?: throw MQTTException( ReasonCode.PROTOCOL_ERROR ) + + if (connectReasonCode !in validReasonCodes) throw MQTTException( + ReasonCode.PROTOCOL_ERROR + ) + val properties = inStream.deserializeProperties(validProperties) return MQTT5Connack( -- GitLab