From cf5a4a4c21885c942a3b7a9631f2be0d676c2cc8 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 27 Jan 2014 01:58:22 +0400 Subject: [PATCH] Fixed callstack overflow CryptoJS hotfix from https://code.google.com/p/crypto-js/issues/detail?id=90 --- app/index.html | 4 ++-- app/js/lib/aes_worker.js | 2 +- app/js/lib/mtproto.js | 10 +++++----- app/js/lib/sha1_worker.js | 2 +- app/vendor/cryptoJS/crypto.js | 7 ++++++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/index.html b/app/index.html index 81180340..d5697005 100644 --- a/app/index.html +++ b/app/index.html @@ -43,12 +43,12 @@ - + - + diff --git a/app/js/lib/aes_worker.js b/app/js/lib/aes_worker.js index 974b9ab6..09f127b7 100644 --- a/app/js/lib/aes_worker.js +++ b/app/js/lib/aes_worker.js @@ -9,7 +9,7 @@ importScripts( '../../vendor/console-polyfill/console-polyfill.js?1', 'mtproto.js', '../../vendor/jsbn/jsbn_combined.js', - '../../vendor/cryptoJS/crypto.js' + '../../vendor/cryptoJS/crypto.js?1' ); onmessage = function (e) { diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index 258f120b..1e929df1 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -1131,7 +1131,7 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu mtpSendReqDhParams(auth); }; worker.onerror = function(error) { - console.log('Worker error', error); + console.log('Worker error', error, error.stack); deferred.reject(error); }; worker.postMessage(auth.pq) @@ -1417,7 +1417,7 @@ factory('MtpAesService', function ($q) { }; } - var worker = new Worker('js/lib/aes_worker.js?1'), + var worker = new Worker('js/lib/aes_worker.js?2'), taskID = 0, awaiting = {}; @@ -1430,7 +1430,7 @@ factory('MtpAesService', function ($q) { // console.log('AES worker message', e.data, deferred); }; worker.onerror = function(error) { - console.log('AES Worker error', error); + console.log('AES Worker error', error, error.stack); }; return { @@ -1469,7 +1469,7 @@ factory('MtpSha1Service', function ($q) { }; } - var worker = new Worker('js/lib/sha1_worker.js?1'), + var worker = new Worker('js/lib/sha1_worker.js?2'), taskID = 0, awaiting = {}; @@ -1482,7 +1482,7 @@ factory('MtpSha1Service', function ($q) { // console.log('sha1 got message', e.data, deferred); }; worker.onerror = function(error) { - console.log('SHA-1 Worker error', error); + console.log('SHA-1 Worker error', error, error.stack); }; return { diff --git a/app/js/lib/sha1_worker.js b/app/js/lib/sha1_worker.js index 809dd0cb..9537471f 100644 --- a/app/js/lib/sha1_worker.js +++ b/app/js/lib/sha1_worker.js @@ -8,7 +8,7 @@ importScripts( '../../vendor/console-polyfill/console-polyfill.js?1', 'mtproto.js', - '../../vendor/cryptoJS/crypto.js' + '../../vendor/cryptoJS/crypto.js?1' ); onmessage = function (e) { diff --git a/app/vendor/cryptoJS/crypto.js b/app/vendor/cryptoJS/crypto.js index 61d792b2..2f6997fa 100644 --- a/app/vendor/cryptoJS/crypto.js +++ b/app/vendor/cryptoJS/crypto.js @@ -223,7 +223,12 @@ var CryptoJS = CryptoJS || (function (Math, undefined) { } } else { // Copy all words at once - thisWords.push.apply(thisWords, thatWords); + // thisWords.push.apply(thisWords, thatWords); + + // HOTFIX from: https://code.google.com/p/crypto-js/issues/detail?id=90 + for (var i = 0; i < thatWords.length; i++) { + thisWords.push(thatWords[i]); + } } this.sigBytes += thatSigBytes;