Skip to content

[CDRIVER-6017] Tweak visitor behavior when finding corrupt BSON #2019

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

vector-of-bool
Copy link
Contributor

This is a minimal fix for some edge cases around BSON iteration/visitation and text validation. A larger change could be made to make the APIs more complete and easier to use, but this is enough to fix a bug related to UTF-8 validation.

We now invoke visit_corrupt in more cases where bson_visit_all cannot properly decode elements, rather than just stopping with the boolean error code.

This also adds an error code to bson_validate for encountering corruption. Previously, it would just set error->code = 0 and the message to corrupt BSON, which is counter-intuitive to those that expect error->code == 0 to indicate success.

See also: CDRIVER-4448

We now invoke `visit_corrupt` in more cases where `bson_visit_all`
cannot properly decode elements, rather than just stopping with the
boolean error code.
@vector-of-bool vector-of-bool requested a review from a team as a code owner May 20, 2025 20:40
@vector-of-bool vector-of-bool requested a review from kevinAlbs May 20, 2025 20:40
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.

1 participant