Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
1.9.3
-
None
-
None
Description
Trying to bson_append a binary value with NULL data asserts.
bson_t ex = BSON_INITIALIZER;
|
/* this asserts */
|
bson_append_binary (&ex, "a", 1, BSON_SUBTYPE_BINARY, NULL /* data */, 0);
|
The assertion occurs here.
I think an empty binary value should be valid. From bsonspec.org:
binary ::= int32 subtype (byte*)
|
Additionally, it seems we can decode JSON with an empty binary value:
bson_t ex = BSON_INITIALIZER;
|
#define JSON(s) #s
|
char* json = JSON({"a": {"$binary": {"base64": "", "subType": "0"}}});
|
bson_init_from_json (&ex, json, strlen(json), NULL);
|
But we can get UBSAN errors when copying a bson_value_t of an empty binary value here:
memcpy (dst->value.v_binary.data,
|
src->value.v_binary.data,
|
dst->value.v_binary.data_len);
|
Attachments
Issue Links
- related to
-
CDRIVER-3340 Appending a bson_value_t containing an empty binary payload may abort
-
- Closed
-