mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Fix crash when we don't have keys for other device when receiving an olm message from it
This commit is contained in:
parent
e4cd8b1c11
commit
e7877ae5af
1 changed files with 11 additions and 5 deletions
12
src/Olm.cpp
12
src/Olm.cpp
|
@ -286,13 +286,19 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
|
||||||
|
|
||||||
bool from_their_device = false;
|
bool from_their_device = false;
|
||||||
for (auto [device_id, key] : otherUserDeviceKeys.device_keys) {
|
for (auto [device_id, key] : otherUserDeviceKeys.device_keys) {
|
||||||
if (key.keys.at("curve25519:" + device_id) == msg.sender_key) {
|
auto c_key = key.keys.find("curve25519:" + device_id);
|
||||||
if (key.keys.at("ed25519:" + device_id) == sender_ed25519) {
|
auto e_key = key.keys.find("ed25519:" + device_id);
|
||||||
|
|
||||||
|
if (c_key == key.keys.end() || e_key == key.keys.end()) {
|
||||||
|
nhlog::crypto()->warn(
|
||||||
|
"Skipping device {} as we have no keys for it.",
|
||||||
|
device_id);
|
||||||
|
} else if (c_key->second == msg.sender_key &&
|
||||||
|
e_key->second == sender_ed25519) {
|
||||||
from_their_device = true;
|
from_their_device = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!from_their_device) {
|
if (!from_their_device) {
|
||||||
nhlog::crypto()->warn("Decrypted event isn't sent from a device "
|
nhlog::crypto()->warn("Decrypted event isn't sent from a device "
|
||||||
"listed by that user! {}",
|
"listed by that user! {}",
|
||||||
|
|
Loading…
Reference in a new issue