Fix protocol version check

Fixes #392

// FREEBIE
This commit is contained in:
lilia 2015-11-09 16:48:14 -08:00
parent 16dc7abe69
commit 596188a630
2 changed files with 8 additions and 4 deletions

View file

@ -37873,8 +37873,10 @@ axolotlInternal.RecipientRecord = function() {
}, },
handlePreKeyWhisperMessage: function(from, blob) { handlePreKeyWhisperMessage: function(from, blob) {
blob.mark(); blob.mark();
if (blob.readUint8() != ((3 << 4) | 3)) { var version = blob.readUint8();
throw new Error("Bad version byte"); 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) { return axolotlInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) {
if (e.message === 'Unknown identity key') { if (e.message === 'Unknown identity key') {

View file

@ -37,8 +37,10 @@
}, },
handlePreKeyWhisperMessage: function(from, blob) { handlePreKeyWhisperMessage: function(from, blob) {
blob.mark(); blob.mark();
if (blob.readUint8() != ((3 << 4) | 3)) { var version = blob.readUint8();
throw new Error("Bad version byte"); 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) { return axolotlInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) {
if (e.message === 'Unknown identity key') { if (e.message === 'Unknown identity key') {