Skip to content

Conversation

ShaneHarvey
Copy link
Member

@ShaneHarvey ShaneHarvey commented Apr 1, 2021

PyObject* InvalidBSON = _error("InvalidBSON");
if (InvalidBSON) {
PyErr_SetNone(InvalidBSON);
PyErr_SetString(InvalidBSON, "invalid field name");
Copy link
Member

Choose a reason for hiding this comment

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

Say why it's invalid?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I went with "field name too large". This can happen when the BSON itself gets corrupted or mangled. For example the null terminator was overwritten or the field was internally truncated like in the test case below.

@ShaneHarvey ShaneHarvey merged commit cc029a1 into mongodb:master Apr 2, 2021
@ShaneHarvey ShaneHarvey deleted the PYTHON-2631 branch April 2, 2021 22:07
ShaneHarvey added a commit to ShaneHarvey/mongo-python-driver that referenced this pull request Apr 19, 2021
ShaneHarvey added a commit to ShaneHarvey/mongo-python-driver that referenced this pull request Apr 19, 2021
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