Open
Conversation
Digest::SHA1#update fails when a very large String is passed in a
single call.
Passing 2**29 bytes (512 MB) or more at once does not update the
message length counter correctly, which results in producing an
incorrect output.
$ ruby -rdigest -e'd=Digest::SHA1.new; d<<"a"*(512*1024*1024); puts d.hexdigest'
40cd9c4b14e7b8d0940a3a92c8a7661fad85a821
$ ruby -rdigest -e'd=Digest::SHA1.new; 512.times{d<<"a"*(1024*1024)}; puts d.hexdigest'
0ea59bfe8787939816796610c73deb1c625e03ed
$ ruby -e'print "a"*(512*1024*1024)'|sha1sum
0ea59bfe8787939816796610c73deb1c625e03ed -
Passing 2**32 bytes or more causes an infinite loop because the loop
counter is too small.
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.
Digest::SHA1#updatefails when a very large String is passed in a single call.Passing 2**29 bytes (512 MB) or more at once does not update the message length counter correctly, which results in producing an incorrect output.
Passing 2**32 bytes or more causes an infinite loop because the loop counter is too small.