Repository navigation
Conversation
These hold String lengths or offsets into them, so they would truncate on mswin once rb_len_t widens. The fallback keeps older Ruby building. https://bugs.ruby-lang.org/issues/22400 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A constant cannot exceed long, so these casts need no rb_len_t. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MAX_UINT and checksum_long compared SIZEOF_LONG, so on mswin they would cast a length to uInt instead of clamping it once rb_len_t widens. The unsigned lengths taken by zstream_expand_buffer_into and zstream_buffer_ungets become rb_ulen_t so that they reach the clamp unnarrowed. Nothing changes while rb_len_t is long. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The int cast turned a remainder longer than INT_MAX into a wrong or negative number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Ruby master added
rb_len_tfor String and Array lengths (Feature #22400). It islongon every platform today, andlongis 32 bits on x64-mswin64, so the lengths this extension keeps inlongwould truncate strings of 2GiB or more oncerb_len_twidens there.This switches the String lengths and offsets in
ext/zlib/zlib.ctorb_len_t, withNUM2LENand%"PRIdLEN"where they come from Ruby or go into an error message.MAX_UINTandchecksum_longnow decide whether to split a length for zlib'suIntbySIZEOF_RB_LEN_Tinstead ofSIZEOF_LONG.Zlib::ZStream#avail_inalso returns the pending input length withLEN2NUMinstead of casting it toint, which turned a length overINT_MAXinto a wrong or negative number.Ruby without
HAVE_RB_LEN_Tgets a fallback that keepslong, so nothing changes on any platform for now.Generated with Claude Code