Skip to content

fix: validate binary input in _from_bytes()#125

Open
sumanjeet0012 wants to merge 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-110
Open

fix: validate binary input in _from_bytes()#125
sumanjeet0012 wants to merge 1 commit into
multiformats:masterfrom
sumanjeet0012:fix-issue-110

Conversation

@sumanjeet0012

Copy link
Copy Markdown

Fixes #110

Description

This pull request adds strict validation to the binary multiaddr parser. It updates _from_bytes() to parse components iteratively using bytes_iter(), ensuring invalid bytes are rejected immediately upon initialization rather than failing later during conversion. It also updates bytes_iter() to catch truncated streams.

Changes

  • Updated Multiaddr._from_bytes() to validate raw binary components fully and raise a BinaryParseError upon encountering unexpected bytes.
  • Updated bytes_iter() to raise a BinaryParseError if a component's byte length is shorter than expected.
  • Added test_invalid_bytes() to tests/test_multiaddr.py to test various invalid multiaddr byte strings.
  • Added a towncrier newsfragment newsfragments/110.bugfix.

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.

_from_bytes() doesn't validate binary input — invalid bytes accepted silently

1 participant