Repository navigation
fix: validate 32-bit declared lengths in the buffer decoder (v2) - #144
Merged
Merged
Conversation
On 32-bit platforms, Array32/Map32/Str32/Bin32 lengths with the high bit set became negative ints, causing panics or silently accepting malformed input. Declared lengths are now validated with LengthFromUint32 (shared with the stream decoder), and offset arithmetic no longer overflows. Ext32 lengths are validated as well.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v2 #144 +/- ##
==========================================
- Coverage 98.08% 97.84% -0.25%
==========================================
Files 74 74
Lines 5993 6019 +26
==========================================
+ Hits 5878 5889 +11
- Misses 67 74 +7
- Partials 48 56 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
Summary
mainintinstead of panickingBackground / Motivation
Same issue as on v3: on 32-bit platforms, high-bit Array32/Map32/Str32/Bin32/Ext32 lengths became negative ints, causing panics or silently accepting malformed input.
Changes
mainLengthFromUint32placed in the existingdecodingutilguard file (v2 has norange.go)Test Plan
go vet ./.../go test -race ./...passmain, verified onlinux/386: fails/panics before the fix, passes afterv2: geomean −0.3%; B/op and allocs/op unchanged