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

Prevent a couple panics on malformed input #236

Merged
merged 2 commits into from
Apr 30, 2021
Merged

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Apr 29, 2021

Fix two possible panics that could be caused by malformed input of compound messages or compressed messages.

The two tests that were added both panicked without these code changes.

numParts was being cast to an int incorrectly, which could lead to
numParts overflowing and reporting 0 after being multiplied by 2.

This would lead to a panic because the check for buffer length would not
properly detect that the buffer was smaller than the number of parts.
When handleCommand is called by handleCompressed it could be called with an empty buffer.
Handle the empty buffer by logging and error and returning.
@dnephin dnephin added the bug label Apr 29, 2021
@dnephin dnephin requested review from picatz and a team April 29, 2021 18:00
@dnephin dnephin merged commit 619135c into master Apr 30, 2021
@dnephin dnephin deleted the dnephin/fix-some-errors branch April 30, 2021 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants