]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mqtt: fix quadratic complexity
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 30 May 2023 10:08:25 +0000 (12:08 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 31 May 2023 05:57:26 +0000 (07:57 +0200)
get_tx_by_pkt_id loops only over the last transactions
in case there is a transaction flood

Ticket: #6100

rust/src/mqtt/mqtt.rs

index 6149ce5982a6cff188fa739fb5a227fb8218d63e..f1c37d83c8810254c92efea3d4926955d23cd2d9 100644 (file)
@@ -170,7 +170,7 @@ impl MQTTState {
     }
 
     pub fn get_tx_by_pkt_id(&mut self, pkt_id: u32) -> Option<&mut MQTTTransaction> {
-        for tx in &mut self.transactions {
+        for tx in &mut self.transactions.range_mut(self.tx_index_completed..) {
             if !tx.complete {
                 if let Some(mpktid) = tx.pkt_id {
                     if mpktid == pkt_id {