Skip to content

Allow mongoc_buffer_t larger than INT_MAX #1467

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
merged 3 commits into from
Nov 6, 2023

Conversation

adriandole
Copy link
Contributor

@adriandole adriandole commented Nov 3, 2023

Remove unnecessary assertion that mongoc_buffer_t is smaller than INT_MAX. Slight refactor.

@@ -5080,6 +5080,49 @@ test_bulk_write_set_client_after_operation (void)
mongoc_client_destroy (client);
}

// Test creating a bulk write with more data than INT_MAX.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this test because it kept getting killed for excessive memory use. See passing runs here.

Comment on lines +38 to +39
buffer->datalen = bson_next_power_of_two (buffer->len + data_size);
buffer->data = (uint8_t *) buffer->realloc_func (
Copy link
Contributor

@eramongodb eramongodb Nov 6, 2023

Choose a reason for hiding this comment

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

Consider adding a size_t overflow check.

const size_t new_datalen = bson_next_power_of_two (buffer->len + data_size);
BSON_ASSERT (new_datalen > buffer->datalen); // Overflow check.
buffer->datalen = bson_next_power_of_two (new_datalen);

@adriandole adriandole merged commit ca724d2 into mongodb:master Nov 6, 2023
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.

3 participants