Skip to content

Discard packets smaller than header offset to prevent slicing panic - #94

Open
SajjadPourali wants to merge 2 commits into
mainfrom
DiscardSmallPackets
Open

SajjadPourali wants to merge 2 commits into
mainfrom
DiscardSmallPackets

Conversation

@SajjadPourali

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings September 18, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test can intermittently coalesce writes and fail to exercise the intended discard path.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Prevents panics when Unix packet-information headers are incomplete by discarding undersized reads and adds regression coverage.

Changes:

  • Discards reads no larger than the configured header offset.
  • Adds a Unix async test for undersized packet data.
File summaries
File Description
src/lib.rs Adds short-read handling and regression testing.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib.rs Outdated
builder.write(&mut packet_data, &[1, 2, 3, 4]).unwrap();

peer.write_all(&[0x00, 0x01]).await.unwrap();
tokio::task::yield_now().await;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in b83c54b by replacing the duplex/yield sequencing with a deterministic chunked test device that returns the malformed 2-byte input and then the valid packet in separate reads.

Co-authored-by: SajjadPourali <20374762+SajjadPourali@users.noreply.github.com>
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