[MONGOCRYPT-2] libmongocrypt does not return the status from an uninitialized mongocrypt_ctx_t Created: 06/Aug/19  Updated: 28/Oct/23  Resolved: 23/Sep/19

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0-beta5

Type: Bug Priority: Major - P3
Reporter: Shane Harvey Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to PYTHON-1937 pymongocrypt add support for explicit... Closed

 Description   

Steps to reproduce:

  1. Create a mongocrypt_ctx_t for explicit encryption
  2. Call mongocrypt_ctx_setopt_key_alt_name where key_alt_name is invalid BSON
  3. Assert mongocrypt_ctx_setopt_key_alt_name fails
  4. Create a new status (mongocrypt_status_new)
  5. Call mongocrypt_ctx_status(ctx, status)
  6. Assert that the status is not ok. This assert fails.

I believe the problem is this check in mongocrypt_ctx_status:

   if (!ctx->initialized) {
      return _mongocrypt_ctx_fail_w_msg (ctx, "ctx NULL or uninitialized");
   }



 Comments   
Comment by Githook User [ 23/Sep/19 ]

Author:

{'username': 'kevinAlbs', 'email': 'kevin.albertson@mongodb.com', 'name': 'Kevin Albertson'}

Message: MONGOCRYPT-2 return status on uninitialized ctx
Branch: master
https://github.com/mongodb/libmongocrypt/commit/3a59b18a9c05647e19a40ae530b2898fcc574301

Comment by Shane Harvey [ 09/Sep/19 ]

I think this ticket should be prioritized higher. The spec says that drivers can rely on libmongocrypt to validate options but with this bug that is not true.

Drivers MAY represent the options types in a way that is idiomatic to the driver or language. E.g. options MAY be a BSON document or dictionary type. The driver MAY forego validating options and instead defer validation to the underlying implementation.

In Python some aspects of some options are validated by Python but some validation is deferred to libmongocrypt. This leads to unhelpful exceptions that give the user no information about what went wrong.

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