Skip to content

fix: 6lowpan could panic when frag datagram_size < 40 #997

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

Merged
merged 1 commit into from
Sep 30, 2024
Merged
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
9 changes: 9 additions & 0 deletions src/iface/interface/sixlowpan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ impl InterfaceInner {
// unless we have a complete one after processing this fragment.
let frag = check!(SixlowpanFragPacket::new_checked(payload));

// From RFC 4944 § 5.3: "The value of datagram_size SHALL be 40 octets more than the value
// of Payload Length in the IPv6 header of the packet."
// We should check that this is true, otherwise `buffer.split_at_mut(40)` will panic, since
// we assume that the decompressed packet is at least 40 bytes.
if frag.datagram_size() < 40 {
net_debug!("6LoWPAN: fragment size too small");
return None;
}

// The key specifies to which 6LoWPAN fragment it belongs too.
// It is based on the link layer addresses, the tag and the size.
let key = FragKey::Sixlowpan(frag.get_key(ieee802154_repr));
Expand Down
Loading