Skip to content

Fix integer overflow in hash_old #218

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

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

MariuszCwikla
Copy link
Contributor

In #216 X509Name.hash was fixed and old implementation renamed to hash_old
However I discovered that old method still wasn't working correclty due to integer overflow:

ruby -e "require 'openssl'; p OpenSSL::X509::Name.new([['CN', 'foo'], ['DC', 'bar']]).hash_old"
3294068023

jruby -e "require 'openssl'; p OpenSSL::X509::Name.new([['CN', 'foo'], ['DC', 'bar']]).hash_old"
-1000899273

Ruby is using unsinged int for this calculation. In JRuby changing int to long solves the issue.

@headius headius added this to the 0.10.5 milestone Nov 12, 2020
@headius
Copy link
Member

headius commented Nov 12, 2020

@MariuszCwikla The PR looks fine but the test should either be added to spec/ruby or test/jruby. The tests under test/mri are copied from CRuby and we do not edit them in our repo.

Thanks for the PR!

@MariuszCwikla
Copy link
Contributor Author

@headius thanks for hints but it seems that jruby-openssl is not consistent jruby repo.
MRI tests even for openssl module are in jruby repo (but disabled).
And there is no test/jruby under jruby-openssl, only test/ruby

@kares kares merged commit cb02f54 into jruby:master Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants