-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-5915: Fix for allocation of bson_t larger than half max size #1891
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The new name doesn't misleadingly imply that the result is always a power of two.
kevinAlbs
approved these changes
Feb 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Changes LGTM. Left a question and possible suggestion for a parameter rename.
eramongodb
requested changes
Feb 28, 2025
* Rename parameters to disambiguate total vs additional size * Document and test expectations around range of sums when computing new sizes * Add additional size check to bson_reserve_buffer() to uphold _bson_grow() expectations on 32-bit * Add warning to bson_reserve_buffer() documentation about lack of document validation in the suggested usage.
Ok, that last commit rolls up I think a reasonable set of changes which clarify the size limits without sprawling too much. From the commit description:
|
kevinAlbs
approved these changes
Mar 3, 2025
eramongodb
approved these changes
Mar 3, 2025
kevinAlbs
pushed a commit
that referenced
this pull request
Mar 4, 2025
…1891) addresses CDRIVER-5915, fixing three closely related problems: * rounding allocation size to the next power of two could cause BSON_MAX_SIZE to be exceeded * bson_reserve_buffer allocated more space than requested, equal to the previous document length * test_bson_reserve_buffer_errors had a flawed "too big" case which was masked by the other two issues additionally: * adds a test for allocating bson_t of exactly max size (on 64-bit systems only) * fix for potential integer overflow in bson_reserve_buffer() with overlong size * comments and assertions related to bson_t max size assumptions
This pull request was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses CDRIVER-5915, fixing three closely related problems:
This fixes allocation for bson_t that are exactly max size, and adds a test which exercises this case on 64-bit systems.