Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking remaining bytes and avoid panicing on truncated messages #150

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

digizeph
Copy link
Member

@digizeph digizeph commented Feb 8, 2024

Highlight

Bytes::split_to will panic if not enough bytes available. We do not want panics so we do the checking first to make sure enough bytes available.

If not enough bytes available, it will send out a TruncatedMsg error. The current iterator will catch the error and skip the remainder of the message.

Breaking change

  • remove IoNotEnoughBytes, and use TruncatedMsg when not enough bytes available to read

This addresses issue #149.

Other changes

  • bump bytes crate version to 1.5.0

IoNotEnoughBytes error essentially indicates truncated messages and
there is not benefits of having this extra error type.

By design, it also means it will send warnings for truncated messages
when attempt to read more than the data source contains.
Bytes::split_to will panic if not enough bytes available. We do not want
panics so we do the checking first to make sure enough bytes available.
If not enough bytes available, it will send out a TruncatedMsg error.
The current iterator will catch the error and skip the remainder of the message.
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a1165a9) 91.85% compared to head (de4a83b) 91.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #150      +/-   ##
==========================================
+ Coverage   91.85%   91.87%   +0.01%     
==========================================
  Files          66       66              
  Lines        8703     8709       +6     
==========================================
+ Hits         7994     8001       +7     
+ Misses        709      708       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@digizeph digizeph merged commit 051e895 into main Feb 8, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant