mongo-go-driver - PR #2418: GODRIVER-3931 Fix bson.Raw.Validate panic on zero-length BSON document

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Duplicate
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      linborland has created PR #2418: GODRIVER-3931 Fix bson.Raw.Validate panic on zero-length BSON document in mongo-go-driver

      Issue Text:
      GODRIVER-3931

        1. Summary

      Adds a minimum length check in bsoncore.Document.Validate() to prevent a panic on a BSON document with a declared length of zero. Returns ErrInvalidLength if the declared length is less than 5 (the BSON minimum) before indexing into the document. Includes a corresponding test case in document_test.go.

        1. Background & Motivation

      bson.Raw.Validate panics on a malformed four-byte input whose declared length is zero. The existing guards in bsoncore.Document.Validate() reject negative and oversized lengths but miss zero, causing d[length-1] to evaluate as d[-1] and produce a runtime index-out-of-range panic.

            Assignee:
            Unassigned
            Reporter:
            TPM Jira Automations Bot
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: