Repository navigation
Conversation
The caseMap methods of ISO-8859-x and Windows-125x map the sharp s (0xDF) to two bytes but checked for only one byte of room in the output buffer, so they wrote one byte past it and threw ArrayIndexOutOfBoundsException, e.g. when upcasing 21 sharp s characters with an input length + 20 buffer. Check for two bytes. Port of ruby/ruby@d582f8f (GHSA-34m4-m9fh-gqp5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zev
marked this pull request as ready for review
November 19, 2026 17:48
Author
|
@headius while this is less of an issue for JRuby, this does help clean it up a bit. |
Member
|
Looks like we both took on the same project. I believe this was addressed by my agent in #73 and has been released in 1.0.66. |
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.
Port of ruby/ruby@d582f8f, the CRuby fix for GHSA-34m4-m9fh-gqp5.
The
caseMapmethods of the ISO-8859-x and Windows-125x encodings upcase or fold the sharp s (0xDF) to two bytes (SS/ss). The loop only checked for one byte of room (toP < toEnd), so the second byte could be written past the end of the output buffer. In CRuby this is a heap overflow. On the JVM it throwsArrayIndexOutOfBoundsException, which JRuby exposes as:The same applies to
swapcase,downcase(:fold)andcasecmp?, in all 14 encodings that expand the sharp s. This PR changes the loop condition totoEnd - toP > 1in those same 14 files, as CRuby did. ISO-8859-5/7 and Windows-1251/1253 never expand a byte, so they are unchanged.Tests
TestCaseMap#testSharpSExpansionDoesNotOverflowruns 1 to 64 sharp s through upcase, fold, swapcase and ana-prefixed upcase for each affected encoding. It sizes and refills buffers the way CRuby and JRuby do (remaining input + 20). It fails with the AIOOBE above without the fix.mvn testpasses: 45 tests, 0 failures (1 skipped, already skipped before this change).Related JRuby fix, for a separate bug where case mapping that outgrows the first buffer returns an empty string: jruby/jruby#10122.
🤖 Generated with Claude Code