[MONGOCRYPT-242] libmongocrypt aborts when mongocrypt_ctx_decrypt_init is called with empty bson string Created: 31/Jan/20  Updated: 30/Mar/22

Status: Backlog
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Oleg Pudeyev (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
is cloned by MONGOCRYPT-243 libmongocrypt segfaults if a handle i... Backlog
Related
related to MONGOCRYPT-241 libmongocrypt uses asserts and termin... Backlog

 Description   

It appears that if mongocrypt_ctx_decrypt_init is called with an empty string as the bson buffer, the result is a BSON_ASSERT failure. In Ruby driver test suite this produces:

(byebug) mongocrypt_ctx_decrypt_init(context.ctx_p, data_p)
/data/mci/dd0591b7a0680c7f9aceb9cc30394457/libmongocrypt/src/mongocrypt-buffer.c:38 _make_owned(): precondition failed: buf->data

I also wrote a C program at https://github.com/p-mongo/tests/blob/master/lmc-empty-bson/test-empty-bson.c which produces:

speed% ./test-empty-bson 
/data/mci/b36facda8d87bede21e55b88e924c257/libmongocrypt/src/mongocrypt-buffer.c:38 _make_owned(): precondition failed: buf->data
zsh: abort      ./test-empty-bson
 
 

libmongocrypt should handle empty bson string in a more graceful way, such as by returning an ordinary error to the caller in this case.


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