From 1f8040998f83697ae7c4094ec6e9528203920d19 Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 15 Jul 2015 13:24:50 -0700 Subject: [PATCH] Fix up array buffer comparison Well that didn't work. Luckily this comparison is primarily enforced at the libaxolotl level. With this and the corresponding change to libaxolotl, remote identity keys are always going to be stored as array buffers going forward. This will cause incompatibility with existing keys stored as strings, so updating to this point requires you to purge your identity key and session store. --- js/axolotl_store.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/axolotl_store.js b/js/axolotl_store.js index 7f23f3ddb..b3686573e 100644 --- a/js/axolotl_store.js +++ b/js/axolotl_store.js @@ -56,13 +56,16 @@ } function equalArrayBuffers(ab1, ab2) { - if (ab1.bytelength !== ab2.bytelength) { + if (!(ab1 instanceof ArrayBuffer && ab2 instanceof ArrayBuffer)) { + return false; + } + if (ab1.byteLength !== ab2.byteLength) { return false; } var result = true; var ta1 = new Uint8Array(ab1); var ta2 = new Uint8Array(ab2); - for (var i = 0; i < ab1.bytelength; ++i) { + for (var i = 0; i < ab1.byteLength; ++i) { if (ta1[i] !== ta2[i]) { result = false; } } return result;