Skip to content

Commit

Permalink
Fix invariant violation if we get a message without piggyback ack whi…
Browse files Browse the repository at this point in the history
…le expecting an ack.

Such messages are not allowed per spec, so we should just ignore them.

Fixes project-chip#22854
  • Loading branch information
bzbarsky-apple committed Oct 20, 2022
1 parent e62498b commit a5a4b20
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,17 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
return CHIP_NO_ERROR;
}

if (IsMessageNotAcked())
{
// The only way we can get here is a spec violation on the other side:
// we sent a message that needs an ack, and the other side responded
// with a message that does not contain an ack for the message we sent.
// Just drop this message; if we delivered it to our delegate it might
// try to send another message-needing-an-ack in response, which would
// violate our internal invariants.
return CHIP_ERROR_INCORRECT_STATE;
}

// Since we got the response, cancel the response timer.
CancelResponseTimer();

Expand Down

0 comments on commit a5a4b20

Please sign in to comment.