Skip to content

fix: avoid panic on undersized packets in Vortex::try_from#103

Merged
gaius-qi merged 1 commit into
dragonflyoss:mainfrom
immanuwell:fix/short-header-parse-panic
Jun 15, 2026
Merged

fix: avoid panic on undersized packets in Vortex::try_from#103
gaius-qi merged 1 commit into
dragonflyoss:mainfrom
immanuwell:fix/short-header-parse-panic

Conversation

@immanuwell

Copy link
Copy Markdown
Contributor

Description

Guard Vortex::try_from before split_to(HEADER_SIZE), so inputs shorter than 6 bytes return InvalidPacket instead of blowing up.

Also adds a regression test for a 3 byte packet. tiny fix, but a real footgun.

Related Issue

Closes #102

Motivation and Context

This is triggerable in practice. Read::read can return fewer bytes than requested, so partial or truncated buffers are normal enough.

Repro on main:

use bytes::Bytes;
use vortex_protocol::Vortex;

let _ = Vortex::try_from(Bytes::from_static(&[1, 2, 3]));

Before this patch it panics in BytesMut::split_to. After this patch it returns invalid vortex packet. pretty straight forward.

Screenshots (if appropriate)

n/a

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix/short-header-parse-panic branch from f9e5244 to a38aa01 Compare June 12, 2026 15:56

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@gaius-qi gaius-qi enabled auto-merge (squash) June 15, 2026 09:25
@gaius-qi gaius-qi merged commit 0d8a230 into dragonflyoss:main Jun 15, 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.

bug: short packet input panics in Vortex::try_from

2 participants