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

Fix String#unpack from using capacity() and causing wrong error #8049

Merged
merged 2 commits into from Dec 21, 2023

Conversation

enebo
Copy link
Member

@enebo enebo commented Dec 21, 2023

JIT and new Prism parser were right-sizing Strings whereas the current parser will create larger than actual string length mostly. This lead to a problem where checkLimit in original unpack code would examine capacity and pass the test even though capacity is not valid data.

The solution is to raise the proper error and use actual encoding limit. the original checkLimit error message is for STRTOUL in MRI in processing the number after the '@' and that was not what we were doing. I am unable to get that RangeError to occur in MRI so I am not sure when it is possible?

JIT and new Prism parser were right-sizing Strings whereas the
current parser will create larger than actual string length mostly.
This lead to a problem where checkLimit in original unpack code
would examine capacity and pass the test even though capacity
is not valid data.

The solution is to raise the proper error and use actual encoding
limit.  the original checkLimit error message is for STRTOUL in MRI
in processing the number after the '@' and that was not what we were
doing.  I am unable to get that RangeError to occur in MRI so I am
not sure when it is possible?
@enebo enebo added this to the JRuby 9.4.6.0 milestone Dec 21, 2023
@enebo enebo merged commit add27fb into jruby:master Dec 21, 2023
74 checks passed
@enebo enebo deleted the fix_unpack branch December 21, 2023 21:45
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.

None yet

1 participant