From 4b1f3656193d26e16730219a03e271c0ddddb05c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 15 Jul 2022 23:38:53 -0400 Subject: [PATCH] Log error on bad packets instead of silent return (#20126) * Log error on bad packets instead of silent return * update message text * fix typo --- src/transport/SessionManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index bdc8573059b81d..2b296eba58d029 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -439,7 +439,12 @@ void SessionManager::OnMessageReceived(const PeerAddress & peerAddress, System:: CHIP_TRACE_PREPARED_MESSAGE_RECEIVED(&peerAddress, &msg); PacketHeader packetHeader; - ReturnOnFailure(packetHeader.DecodeAndConsume(msg)); + CHIP_ERROR err = packetHeader.DecodeAndConsume(msg); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Inet, "Failed to decode packet header: %" CHIP_ERROR_FORMAT, err.Format()); + return; + } if (packetHeader.IsEncrypted()) {