Skip to content
Snippets Groups Projects
Verified Commit 6222ae88 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Fix crash on invalid utf8 in decrypted events

parent e8e48305
No related branches found
No related tags found
No related merge requests found
Pipeline #1483 passed
......@@ -1048,24 +1048,24 @@ decryptEvent(const MegolmSessionIndex &index,
return {DecryptionErrorCode::DecryptionFailed, e.what(), std::nullopt};
}
// Add missing fields for the event.
json body = json::parse(msg_str);
body["event_id"] = event.event_id;
body["sender"] = event.sender;
body["origin_server_ts"] = event.origin_server_ts;
body["unsigned"] = event.unsigned_data;
try {
// Add missing fields for the event.
json body = json::parse(msg_str);
body["event_id"] = event.event_id;
body["sender"] = event.sender;
body["origin_server_ts"] = event.origin_server_ts;
body["unsigned"] = event.unsigned_data;
// relations are unencrypted in content...
mtx::common::add_relations(body["content"], event.content.relations);
// relations are unencrypted in content...
mtx::common::add_relations(body["content"], event.content.relations);
mtx::events::collections::TimelineEvent te;
try {
mtx::events::collections::TimelineEvent te;
mtx::events::collections::from_json(body, te);
return {std::nullopt, std::nullopt, std::move(te.data)};
} catch (std::exception &e) {
return {DecryptionErrorCode::ParsingFailed, e.what(), std::nullopt};
}
return {std::nullopt, std::nullopt, std::move(te.data)};
}
crypto::Trust
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment