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

fix(rumqttd/protocol/v5): Parse ConnAck and UnsubAck packets instead of panicking #812

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rumqttd/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- MQTT keep alive interval
- record client id for remote link's span
- session present flag in connack
- (MQTT v5) handle connack and unsuback packets properly instead of panic.

### Security

Expand Down
1 change: 0 additions & 1 deletion rumqttd/src/protocol/v4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ impl Protocol for V4 {
// v4 Disconnect packet gets handled in the previous check, this branch gets hit when
// Disconnect packet has properties which is only valid for v5
PacketType::Disconnect => return Err(Error::InvalidProtocol),
_ => unreachable!(),
};

Ok(packet)
Expand Down
9 changes: 8 additions & 1 deletion rumqttd/src/protocol/v5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ impl Protocol for V5 {
connect::read(fixed_header, packet)?;
Packet::Connect(connect, properties, will, willproperties, login)
}
PacketType::ConnAck => {
let (puback, properties) = connack::read(fixed_header, packet)?;
Packet::ConnAck(puback, properties)
}
PacketType::Publish => {
let (publish, properties) = publish::read(fixed_header, packet)?;
Packet::Publish(publish, properties)
Expand All @@ -408,6 +412,10 @@ impl Protocol for V5 {
let (unsubscribe, properties) = unsubscribe::read(fixed_header, packet)?;
Packet::Unsubscribe(unsubscribe, properties)
}
PacketType::UnsubAck => {
let (unsuback, properties) = unsuback::read(fixed_header, packet)?;
Packet::UnsubAck(unsuback, properties)
}
PacketType::PingReq => Packet::PingReq(PingReq),
PacketType::PingResp => Packet::PingResp(PingResp),
PacketType::Disconnect => {
Expand All @@ -426,7 +434,6 @@ impl Protocol for V5 {
let (pubcomp, properties) = pubcomp::read(fixed_header, packet)?;
Packet::PubComp(pubcomp, properties)
}
_ => unreachable!(),
};

Ok(packet)
Expand Down