]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mqtt: fix transaction completion
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 2 Dec 2021 09:29:40 +0000 (10:29 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 7 Dec 2021 06:56:36 +0000 (07:56 +0100)
Ticket: 4862

A transaction to client is always considered
complete in the direction to server and vice versa.
Otherwise, transactions are never complete for
AppLayerParserTransactionsCleanup

rust/src/mqtt/mqtt.rs

index 700ba77f16f920edf1716b8b2952d45d4c70876d..f377afab23b1b9d4b4c1b24240e666764124df93 100644 (file)
@@ -627,13 +627,14 @@ pub unsafe extern "C" fn rs_mqtt_tx_get_alstate_progress(
     direction: u8,
 ) -> std::os::raw::c_int {
     let tx = cast_pointer!(tx, MQTTTransaction);
-    if tx.complete {
-        if direction == Direction::ToServer.into() {
-            if tx.toserver {
+    match direction.into() {
+        Direction::ToServer => {
+            if tx.complete || tx.toclient {
                 return 1;
             }
-        } else if direction == Direction::ToClient.into() {
-            if tx.toclient {
+        }
+        Direction::ToClient => {
+            if tx.complete || tx.toserver {
                 return 1;
             }
         }