Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mqtt: fix consumed bytes computation for truncated msg #7264

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions rust/src/mqtt/mqtt.rs
Expand Up @@ -427,25 +427,25 @@ 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)) => {
SCLogDebug!("request msg {:?}", msg);
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 = &current[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;
}
Expand Down Expand Up @@ -483,26 +483,26 @@ 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)) => {
SCLogDebug!("response msg {:?}", msg);
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 = &current[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;
}
Expand Down