From 596188a63089ed3354330f1ca9ee053fb73630e3 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 9 Nov 2015 16:48:14 -0800 Subject: [PATCH] Fix protocol version check Fixes #392 // FREEBIE --- js/libtextsecure.js | 6 ++++-- libtextsecure/axolotl_wrapper.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 51689d825..932439647 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37873,8 +37873,10 @@ axolotlInternal.RecipientRecord = function() { }, handlePreKeyWhisperMessage: function(from, blob) { blob.mark(); - if (blob.readUint8() != ((3 << 4) | 3)) { - throw new Error("Bad version byte"); + var version = blob.readUint8(); + if ((version & 0xF) > 3 || (version >> 4) < 3) { + // min version > 3 or max version < 3 + throw new Error("Incompatible version byte"); } return axolotlInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) { if (e.message === 'Unknown identity key') { diff --git a/libtextsecure/axolotl_wrapper.js b/libtextsecure/axolotl_wrapper.js index a35315247..b54629443 100644 --- a/libtextsecure/axolotl_wrapper.js +++ b/libtextsecure/axolotl_wrapper.js @@ -37,8 +37,10 @@ }, handlePreKeyWhisperMessage: function(from, blob) { blob.mark(); - if (blob.readUint8() != ((3 << 4) | 3)) { - throw new Error("Bad version byte"); + var version = blob.readUint8(); + if ((version & 0xF) > 3 || (version >> 4) < 3) { + // min version > 3 or max version < 3 + throw new Error("Incompatible version byte"); } return axolotlInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) { if (e.message === 'Unknown identity key') {