bug: chunkedReader.Read read up to math.MaxInt on 32bit platforms #137
No reviewers
Labels
No labels
breaking-change
bug
dependencies
duplicate
enhancement
go
good first issue
help wanted
invalid
investigation
proposal
proposal-accepted
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nemith/netconf!137
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "brb/push-pkyokursztlx"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The chunkedWriter correctly works with the max
intsize on 32bit platforms but the read side was still assuming math.MaxUint32. Since len(p) is weirdly signed this doesn't work so cap it at Math.MaxInt the same way we do for the writer.I really wish Go used usize for things like this cause this is just a pain in the ass.
Pull request overview
This PR fixes a bug in the chunkedReader implementation where it was using
math.MaxUint32instead ofmath.MaxIntto cap buffer sizes on 32-bit platforms. Since Go slice lengths are signed integers (typeint), this caused issues on 32-bit systems wheremath.MaxUint32exceeds the maximum value ofint.Key changes:
maxChunkSizeconstant fromchunkedWriter.Writemethod to package-level scope for reusechunkedReader.Readto usemaxChunkSizeinstead ofmath.MaxUint32, ensuring consistency with the writer and proper handling on 32-bit platforms💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -139,6 +139,12 @@ func (f *Framer) MsgWriter() (io.WriteCloser, error) {The comment mentions "MaxInt32" but should refer to "MaxInt" for accuracy. On 32-bit systems, math.MaxInt equals math.MaxInt32, but on 64-bit systems, math.MaxInt equals math.MaxInt64. The comment should be updated to reflect that slice lengths are limited to math.MaxInt (not specifically MaxInt32).