[GODRIVER-1918] panic in bsoncore StringValue function on malformed document Created: 11/Mar/21  Updated: 28/Oct/23  Resolved: 24/Mar/21

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.5.1

Type: Bug Priority: Major - P3
Reporter: Stephen White Assignee: Benji Rewis (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documentation Changes: Not Needed

 Description   

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

 



 Comments   
Comment by Githook User [ 24/Mar/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-1918 Check for zero length in readstring (#613)
Branch: release/1.5
https://github.com/mongodb/mongo-go-driver/commit/6ea353a400000498cf3591dacb61d91478067751

Comment by Githook User [ 24/Mar/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-1918 Check for zero length in readstring (#613)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/801470d71159ef2502bbd1932d4628229bda0850

Comment by Benji Rewis (Inactive) [ 17/Mar/21 ]

https://github.com/mongodb/mongo-go-driver/pull/613

Generated at Thu Feb 08 08:37:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.