-
Type:
Task
-
Resolution: Duplicate
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
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
-
- 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.
-
- 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.
- duplicates
-
GODRIVER-3931 Go driver bson.Raw.Validate panic on zero-length BSON document
-
- Closed
-