Skip to content

Commit

Permalink
Check whether we actually have a GroupId before trying to use it. (pr…
Browse files Browse the repository at this point in the history
…oject-chip#36729)

This avoids a crash on malformed messages (which will get dropped further down
the pipeline, due to not being valid).

Fixes project-chip#36711

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
bzbarsky-apple and andy31415 authored Dec 5, 2024
1 parent 6af4037 commit dfe2477
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,15 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const
}
else
{
ChipLogProgress(ExchangeManager, "Received Groupcast Message with GroupId 0x%04X (%d)",
packetHeader.GetDestinationGroupId().Value(), packetHeader.GetDestinationGroupId().Value());
if (packetHeader.GetDestinationGroupId().HasValue())
{
ChipLogProgress(ExchangeManager, "Received Groupcast Message with GroupId 0x%04X (%d)",
packetHeader.GetDestinationGroupId().Value(), packetHeader.GetDestinationGroupId().Value());
}
else
{
ChipLogProgress(ExchangeManager, "Received Groupcast Message without GroupId");
}
}

// Do not handle messages that don't match an existing exchange on an
Expand Down

0 comments on commit dfe2477

Please sign in to comment.