fix: Handle duplicate indexes properly

This commit is contained in:
Sorunome 2020-09-10 11:24:37 +02:00 committed by Christian Pauly
parent e08f35b5d0
commit 64b8e01444

View file

@ -148,6 +148,13 @@ class Encryption {
// TODO: maybe clear outbound session, if it is ours // TODO: maybe clear outbound session, if it is ours
throw (DecryptError.CHANNEL_CORRUPTED); throw (DecryptError.CHANNEL_CORRUPTED);
} }
final existingIndex = inboundGroupSession.indexes.entries.firstWhere(
(e) => e.value == decryptResult.message_index,
orElse: () => null);
if (existingIndex != null && existingIndex.key != messageIndexKey) {
// TODO: maybe clear outbound session, if it is ours
throw (DecryptError.CHANNEL_CORRUPTED);
}
inboundGroupSession.indexes[messageIndexKey] = inboundGroupSession.indexes[messageIndexKey] =
decryptResult.message_index; decryptResult.message_index;
if (!haveIndex) { if (!haveIndex) {