Skip to content

CDRIVER-2928 assert returned values of bson_init_static #1351

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 4 commits into from
Jul 21, 2023

Conversation

kevinAlbs
Copy link
Collaborator

Summary

  • assert returned values of bson_init_static

Background & Motivation

Addresses Coverity issues with CIDs: 134030, 134029, 120108, and 120107.

The test macro ASSERT was used in test code. BSON_ASSERT was used in driver code.

bson_init_static returns false on failure. Failure may occur if the input BSON data is invalid. Callers ignoring the returned value have been updated to assert to result in an early error on invalid BSON data input.

@kevinAlbs kevinAlbs marked this pull request as ready for review July 20, 2023 17:11
@kevinAlbs kevinAlbs requested a review from joshbsiegel July 20, 2023 17:11
Copy link
Contributor

@joshbsiegel joshbsiegel left a comment

Choose a reason for hiding this comment

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

Should we also be asserting the 3 calls to bson_init_static that I see in bson-dsl.h for completeness?

@kevinAlbs
Copy link
Collaborator Author

Should we also be asserting the 3 calls to bson_init_static that I see in bson-dsl.h for completeness?

Good catch. Done.

@kevinAlbs kevinAlbs requested a review from joshbsiegel July 20, 2023 18:01
Copy link
Contributor

@joshbsiegel joshbsiegel left a comment

Choose a reason for hiding this comment

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

LGTM. Auto-formatting is fun.

@kevinAlbs kevinAlbs merged commit 3a3b3f7 into mongodb:master Jul 21, 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.

2 participants