diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index 65e0e87359ed..e9fed17dc041 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -427,7 +427,6 @@ impl MQTTState { while current.len() > 0 { - let mut skipped = false; SCLogDebug!("request: handling {}", current.len()); match parse_message(current, self.protocol_version, self.max_msg_len) { Ok((rem, msg)) => { @@ -435,17 +434,18 @@ impl MQTTState { if let MQTTOperation::TRUNCATED(ref trunc) = msg.op { SCLogDebug!("found truncated with skipped {} current len {}", trunc.skipped_length, current.len()); if trunc.skipped_length >= current.len() { - skipped = true; self.skip_request = trunc.skipped_length - current.len(); + self.handle_msg(msg, true); + return AppLayerResult::ok(); } else { + consumed += trunc.skipped_length; current = ¤t[trunc.skipped_length..]; + self.handle_msg(msg, true); self.skip_request = 0; + continue; } } self.handle_msg(msg, false); - if skipped { - return AppLayerResult::ok(); - } consumed += current.len() - rem.len(); current = rem; } @@ -483,7 +483,6 @@ impl MQTTState { } while current.len() > 0 { - let mut skipped = false; SCLogDebug!("response: handling {}", current.len()); match parse_message(current, self.protocol_version, self.max_msg_len as usize) { Ok((rem, msg)) => { @@ -491,18 +490,19 @@ impl MQTTState { if let MQTTOperation::TRUNCATED(ref trunc) = msg.op { SCLogDebug!("found truncated with skipped {} current len {}", trunc.skipped_length, current.len()); if trunc.skipped_length >= current.len() { - skipped = true; self.skip_response = trunc.skipped_length - current.len(); + self.handle_msg(msg, true); + SCLogDebug!("skip_response now {}", self.skip_response); + return AppLayerResult::ok(); } else { + consumed += trunc.skipped_length; current = ¤t[trunc.skipped_length..]; + self.handle_msg(msg, true); self.skip_response = 0; + continue; } - SCLogDebug!("skip_response now {}", self.skip_response); } self.handle_msg(msg, true); - if skipped { - return AppLayerResult::ok(); - } consumed += current.len() - rem.len(); current = rem; }