Skip to content

Reject oversized blocks_by_range requests and add tests - #450

Closed
devylongs wants to merge 1 commit into
mainfrom
codex/fix-typo-in-codebase-0d8v0i
Closed

devylongs wants to merge 1 commit into
mainfrom
codex/fix-typo-in-codebase-0d8v0i

Conversation

@devylongs

Copy link
Copy Markdown
Collaborator

Motivation

  • Ensure peers cannot send compressed range requests larger than MaxCompressedPayloadSize to avoid resource exhaustion or unexpected behavior.

Description

  • Add a readRangeRequest helper that reads up to MaxCompressedPayloadSize+1 bytes and returns a specific error when the compressed request exceeds MaxCompressedPayloadSize.
  • Introduce errRangeRequestTooLarge and update handleBlocksByRangeRequest to use readRangeRequest and respond with RespInvalidRequest and message "request too large" when the helper reports an oversized request.
  • Add unit tests and a test stream shim: TestReadRangeRequestSizeLimit validates reading at and above the limit, and TestBlocksByRangeRejectsOversizedRequest ensures oversized requests are rejected and block lookup is not invoked.

Testing

  • Ran unit tests in the internal/p2p package including TestReadRangeRequestSizeLimit and TestBlocksByRangeRejectsOversizedRequest.
  • All added and existing tests in the package passed.

Codex Task

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T17:56:12.306397Z a48aaf2 PR opened
🔒 Security Review ✅ Completed 2026-09-24T17:56:51.504995Z a48aaf2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devylongs devylongs closed this Sep 24, 2026
@devylongs
devylongs deleted the codex/fix-typo-in-codebase-0d8v0i branch September 24, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant