Skip to content

fix(traffic): bound BlobRange without overflowing int64 - #334

Merged
BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/blobrange-overflow
Nov 18, 2026
Merged

BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/blobrange-overflow

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

BlobRange clipped with offset+length > size. Both values are int64, so a small offset and a length near MaxInt64 wrap, the condition is false, and make([]byte, length) can panic or exhaust memory.

Clip with length > size-offset instead.

Tested: go test ./traffic -run TestClampBlobRange pass.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length > size-offset is the correct bound and the overflow case is covered. Negative offset and the empty blob keep their previous behavior. Thanks.

offset+length > size wraps when length is near MaxInt64, so the cap is
skipped and make([]byte, length) can exhaust memory. Compare length
against size-offset instead.
@BaaRai
BaaRai force-pushed the fix/blobrange-overflow branch from a705729 to 74c9c17 Compare November 18, 2026 16:22
@BaaRai
BaaRai merged commit 92254a2 into BaaRai:main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants