Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError/ NegativeArraySizeException on large arrays #2

Closed
mprevel opened this issue Jul 21, 2020 · 2 comments
Closed

OutOfMemoryError/ NegativeArraySizeException on large arrays #2

mprevel opened this issue Jul 21, 2020 · 2 comments
Labels

Comments

@mprevel
Copy link

mprevel commented Jul 21, 2020

Hello,

Sha256:95 int newMessageLength = message.length + 1 + 8; can lead to a negative value that is used at Sha256:100 final byte[] paddedMessage = new byte[newMessageLength]; when message. length is greater than Integer.MAX_VALUE - 9 and resulting in a NegativeArraySizeException.

It may also lead to an OutOfMemoryError when building the array with an integer near Integer.MAX_VALUE since array max size is platform specific and can be a few bytes under Integer_MAX_VALUE.

@meyfa
Copy link
Owner

meyfa commented Jul 22, 2020

Confirmed. Probably needs a major overhaul of the padding logic for this to be fixed, but is doable because of the block-wise nature of SHA256.

@meyfa
Copy link
Owner

meyfa commented Aug 10, 2020

I hope to have fixed this issue in the latest commits. Please feel free to comment or open another issue if you notice anything else. Thanks!

@meyfa meyfa closed this as completed Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants