fix(go): add bounds checking to DeserializeStreams for payloads > 64KB#3165
fix(go): add bounds checking to DeserializeStreams for payloads > 64KB#3165atharvalade wants to merge 1 commit into
Conversation
10dedb2 to
18ae55f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3165 +/- ##
=========================================
Coverage 73.78% 73.78%
Complexity 943 943
=========================================
Files 1200 1200
Lines 109094 109106 +12
Branches 85994 85994
=========================================
+ Hits 80492 80502 +10
- Misses 25866 25867 +1
- Partials 2736 2737 +1
🚀 New features to boost your workflow:
|
18ae55f to
e40eac9
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR. Thank you for your contribution! |
|
/ready |
slbotbm
left a comment
There was a problem hiding this comment.
one comment, otherwise lgtm
| if streams[0].Id != 1 || streams[0].Name != "stream-one" { | ||
| t.Errorf("stream[0] = {Id:%d, Name:%q}, want {Id:1, Name:\"stream-one\"}", streams[0].Id, streams[0].Name) | ||
| } | ||
| if streams[1].Id != 2 || streams[1].Name != "s2" { | ||
| t.Errorf("stream[1] = {Id:%d, Name:%q}, want {Id:2, Name:\"s2\"}", streams[1].Id, streams[1].Name) | ||
| } | ||
| if streams[2].Id != 3 || streams[2].Name != "third" { | ||
| t.Errorf("stream[2] = {Id:%d, Name:%q}, want {Id:3, Name:\"third\"}", streams[2].Id, streams[2].Name) | ||
| } |
There was a problem hiding this comment.
Here, only the Id and that name are being checked. I think it would be better to check everything.
There was a problem hiding this comment.
Good catch, now checking all fields
|
@slbotbm use /author after you are done with review :) /author |
2ca3da2 to
91e6df0
Compare
|
/ready |
Which issue does this PR close?
Closes #3130
Rationale
DeserializeStreamsandDeserializeToStreamhad zero bounds checking and no error propagation, causing silent data corruption for stream lists larger than 64KB.What changed?
DeserializeToStreamperformed raw slice accesses without validating that the payload contained enough bytes for the 33-byte fixed header or the variable-length name. With large payloads (>64KB), any framing misalignment caused position drift—subsequent streams were deserialized from wrong offsets, silently returning corrupted data with no error.The fix adds bounds validation before every access in
DeserializeToStream(returns error on insufficient data), propagates errors throughDeserializeStreams, and updates the TCP caller. A new test file covers single-stream, multi-stream, truncated header/name, corrupted payload, max-length name, and a 70KB+ regression test that verifies every field of ~1000 streams.Local Execution
AI Usage