Fix array length Allocation failed issue when Message is huge#255
Open
fanazhe wants to merge 3 commits intobrix:developfrom
Open
Fix array length Allocation failed issue when Message is huge#255fanazhe wants to merge 3 commits intobrix:developfrom
fanazhe wants to merge 3 commits intobrix:developfrom
Conversation
Member
Contributor
|
@fanazhe would you mind adding a test case? I don't known which algorithom module you used, more information help us verified your PR :) |
Author
|
@Alanscut I've pushed more code to fix huge array length issues. The test code is quite slow running on my computer and I believe it is not suitable to run in browser, so I didn't put it into test folder but only pasted it here. const path = './build/';
const length = 400 * 1024 * 1024; // 400MB
const message = 'A'.repeat(length);
const privateKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
// Begin large message test
require(path + 'md5')(message); console.log('md5 done');
require(path + 'ripemd160')(message); console.log('ripemd160 done');
require(path + 'sha1')(message); console.log('sha1 done');
require(path + 'sha3')(message); console.log('sha3 done');
require(path + 'sha224')(message); console.log('sha224 done');
require(path + 'sha256')(message); console.log('sha256 done');
require(path + 'sha384')(message); console.log('sha384 done');
require(path + 'sha512')(message); console.log('sha512 done');
require(path + 'hmac-md5')(message, privateKey); console.log('hmac-md5 done');
require(path + 'hmac-ripemd160')(message, privateKey); console.log('hmac-ripemd160 done');
require(path + 'hmac-sha1')(message, privateKey); console.log('hmac-sha1 done');
require(path + 'hmac-sha3')(message, privateKey); console.log('hmac-sha3 done');
require(path + 'hmac-sha224')(message, privateKey); console.log('hmac-sha224 done');
require(path + 'hmac-sha256')(message, privateKey); console.log('hmac-sha256 done');
require(path + 'hmac-sha384')(message, privateKey); console.log('hmac-sha384 done');
require(path + 'hmac-sha512')(message, privateKey); console.log('hmac-sha512 done');
// Done large message testYou can use this code to verify my PR. Thanks! |
|
why i not found yours answer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using crypto-js to encrypt and decrypt a file larger than 400MB, the program always crashes and says "FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory".
After some research I found crypto-js directly access some array elements which have large index, which caused V8 engine to crash.
This answer https://stackoverflow.com/questions/55465821/55474570 is related.