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

GODRIVER-1918 Check for zero length in readstring #613

Merged
merged 1 commit into from Mar 24, 2021

Conversation

benjirewis
Copy link
Contributor

GODRIVER-1918

Adds a check for zero length strings in readstring to ensure that a malformed string such as {0x0, 0x0, 0x0, 0x0} will not panic with StringValue() and StringValueOk().

Adds two new tests to verify no panic in the case of zero-length strings.

iwysiu
iwysiu approved these changes Mar 17, 2021
@benjirewis
Copy link
Contributor Author

In case anyone is curious, a BSON string can never have length 0. An empty string in BSON is represented as 0x1, 0x0, 0x0, 0x0, 0x0 in bytes.

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM!

@benjirewis benjirewis merged commit 801470d into mongodb:master Mar 24, 2021
15 checks passed
@benjirewis benjirewis deleted the stringValuePanic.1918 branch March 24, 2021 22:18
faem pushed a commit to kubedb/mongo-go-driver that referenced this pull request Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants