panic in bsoncore StringValue function on malformed document

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 1.5.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Problem Statement/Rationale

      v := bsoncore.Value{
        Type: bsontype.String,
        Data: []byte("\x00\x00\x00\x00"),
      }
      _, _ = v.StringValueOK()
      

      This code will throw a panic, due to an invalid slice operation on
      https://github.com/mongodb/mongo-go-driver/blob/master/x/bsonx/bsoncore/bsoncore.go#L825

       

              Assignee:
              Benji Rewis (Inactive)
              Reporter:
              Stephen White
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: