From eb50b8ebe4447cafe23d5f1d4ca9351e594e917e Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sat, 26 Feb 2022 22:22:51 +0100 Subject: Check that decrypted events are for the current room --- lib/room.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/room.cpp b/lib/room.cpp index ea9915c3..d0ac10f9 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1487,7 +1487,13 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent) // qCWarning(E2EE) << "Encrypted message is empty"; return {}; } - return encryptedEvent.createDecrypted(decrypted); + auto decryptedEvent = encryptedEvent.createDecrypted(decrypted); + if (decryptedEvent->roomId() == id()) { + return decryptedEvent; + } else { + qCWarning(E2EE) << "Decrypted event" << encryptedEvent.id() << "not for this room; discarding."; + return nullptr; + } #endif // Quotient_E2EE_ENABLED } -- cgit v1.2.3 From 6e092bd322f52bde1b037d600a7ce71f5b30f2e4 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 27 Feb 2022 14:06:27 +0100 Subject: Apply suggestions --- lib/room.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index d0ac10f9..6197b3a2 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1490,10 +1490,9 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent) auto decryptedEvent = encryptedEvent.createDecrypted(decrypted); if (decryptedEvent->roomId() == id()) { return decryptedEvent; - } else { - qCWarning(E2EE) << "Decrypted event" << encryptedEvent.id() << "not for this room; discarding."; - return nullptr; } + qCWarning(E2EE) << "Decrypted event" << encryptedEvent.id() << "not for this room; discarding."; + return {}; #endif // Quotient_E2EE_ENABLED } -- cgit v1.2.3