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

Add out of bounds check for encoding/decoding #42

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

dngrudin
Copy link
Contributor

Added the ability to select the encoding/decoding mode. If the safe mode is selected, then the buffer is checked for going beyond the boundaries. In this mode, the result is wrapped in std::optional.
In the unsafe mode (which is selected by default), no checks are performed. The encoding result is similar to what it was before the changes.
The decoding result is almost compatible with what it was before the changes (when assigning the result to a variable with the type 'auto', nothing in the old code will need to be changed).

Also the code is prepared for compilation with the flags -Wall -Werror -Wextra -Wconversion -pedantic.

@dngrudin dngrudin force-pushed the buffer-overflow-check branch 4 times, most recently from c4fe3ae to c31559c Compare November 21, 2024 12:53
@PragmaTwice
Copy link
Owner

Thank you for your great work! I'll take a review this week.

Copy link
Owner

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

Looks great! Comment left above.

@dngrudin dngrudin force-pushed the buffer-overflow-check branch 5 times, most recently from aa4fd38 to 6942b30 Compare November 25, 2024 12:01
Copy link
Owner

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

Generally looks good to me! Just one comment.

Copy link
Owner

Choose a reason for hiding this comment

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

Wow the abstraction over "mode" looks great!

include/protopuf/coder.h Show resolved Hide resolved
@dngrudin dngrudin force-pushed the buffer-overflow-check branch from 6942b30 to 426473d Compare November 27, 2024 09:32
Copy link
Owner

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your contribution!

@PragmaTwice PragmaTwice merged commit 2ab76da into PragmaTwice:master Nov 27, 2024
7 of 9 checks passed
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