From 7e8b1319a522591cd39b5346fc8b4eefa7000e81 Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 20 May 2015 12:40:18 -0700 Subject: [PATCH] Ignore sync contexts on messages not from ourselves But process the rest of the message normally. --- js/libtextsecure.js | 6 ++++-- libtextsecure/helpers.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index f889caa57..ff7d2b0f2 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38741,8 +38741,10 @@ textsecure.processDecrypted = function(decrypted, source) { if (decrypted.flags == null) decrypted.flags = 0; - if (decrypted.sync !== null && textsecure.storage.user.getNumber() != source) - throw new Error("Got sync context on a message not from a peer device"); + if (decrypted.sync !== null && textsecure.storage.user.getNumber() != source) { + // Ignore erroneous or malicious sync context from different number + decrypted.sync = null; + } if ((decrypted.flags & textsecure.protobuf.PushMessageContent.Flags.END_SESSION) == textsecure.protobuf.PushMessageContent.Flags.END_SESSION) { diff --git a/libtextsecure/helpers.js b/libtextsecure/helpers.js index 419d07433..4e9eddc8f 100644 --- a/libtextsecure/helpers.js +++ b/libtextsecure/helpers.js @@ -156,8 +156,10 @@ textsecure.processDecrypted = function(decrypted, source) { if (decrypted.flags == null) decrypted.flags = 0; - if (decrypted.sync !== null && textsecure.storage.user.getNumber() != source) - throw new Error("Got sync context on a message not from a peer device"); + if (decrypted.sync !== null && textsecure.storage.user.getNumber() != source) { + // Ignore erroneous or malicious sync context from different number + decrypted.sync = null; + } if ((decrypted.flags & textsecure.protobuf.PushMessageContent.Flags.END_SESSION) == textsecure.protobuf.PushMessageContent.Flags.END_SESSION) {