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 3 commits into
Conversation
10dedb2 to
18ae55f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3165 +/- ##
============================================
- Coverage 74.10% 72.79% -1.31%
Complexity 943 943
============================================
Files 1159 1117 -42
Lines 102033 96123 -5910
Branches 79083 73289 -5794
============================================
- Hits 75607 69976 -5631
+ Misses 23765 23602 -163
+ Partials 2661 2545 -116
🚀 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.
|
@slbotbm use /author after you are done with review :) /author |
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