Skip to content

size_hint returns incorrect delta for truncated frames #2086

@Shourya742

Description

@Shourya742

Sv2Frame::size_hint is documented to return:

  • 0 when the frame length matches the header,
  • a negative value when bytes are missing,
  • a positive value when extra bytes are present.

However, when the header parses successfully but the payload is shorter than expected, the function returns an incorrect positive value instead of a negative delta.

The current implementation computes:

(bytes.len() - Header::SIZE) as isize + header.len() as isize

This produces a positive result even when bytes are missing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions