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

Avoid panics when decoding invalid messages #92

Merged
merged 2 commits into from
Dec 16, 2022

Conversation

dylan-bourque
Copy link
Collaborator

This PR adds bounds checks to all paths in Decoder to avoid panics when attempting to decode invalid/corrupt Protobuf messages. The changes had a minimal impact on benchmarks, so the general safety is a net win.

I also addressed a new linter warning that was introduced in v0.15.0 and added unit tests for the ExtensionFieldNumber(any) int function

added bounds checks to all paths in `Decoder` to prevent panics
added unit and fuzz test for `Decoder.DecodeTag()`
updated Google V1 path in `ExtensionFieldNumber()` to address linter warning
added unit tests for `ExtensionFieldNumber()`
@dylan-bourque dylan-bourque changed the title Fix/panics when decoding invalid messages Avoid panics when decoding invalid messages Dec 15, 2022
Copy link

@wmorgan6796 wmorgan6796 left a comment

Choose a reason for hiding this comment

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

LGTM

@dylan-bourque dylan-bourque merged commit 93ef2b2 into main Dec 16, 2022
@dylan-bourque dylan-bourque deleted the fix/panics-when-decoding-invalid-messages branch December 16, 2022 01:13
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.

2 participants