Skip to content

PYTHON-6111 C extension accepts BSON documents where element data overlaps the document terminator - #35

Open
blink1073 wants to merge 2 commits into
mainfrom
PYTHON-6111
Open

blink1073 wants to merge 2 commits into
mainfrom
PYTHON-6111

Conversation

@blink1073

Copy link
Copy Markdown
Owner

PYTHON-6111

Changes in this PR

  • The C BSON decoder accepted documents where an element's value consumed the document terminator byte; the pure-Python decoder rejects them with InvalidBSON.
  • Adds bounds checks to the boolean and regex element handlers so the C decoder matches the pure-Python decoder.
  • No public APIs changed. All reads stay within the caller's buffer.

Test Plan

  • Added a regression test with terminator-overlapping boolean and regex payloads, exercised through all decode entry points and buffer types.
  • Confirmed the test fails without the fix and passes with it; the full test/test_bson.py suite and just lint-manual pass.
  • just typing (mypy) crashes on an environment issue unrelated to this diff; re-run on a clean checkout before merge.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). (No followup work identified.)

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

This branch has not been deployed

No deployments
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