[MONGOCRYPT-438] Error on encryption or decryption may result in memory leak Created: 02/Jun/22  Updated: 28/Oct/23  Resolved: 03/Jun/22

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: 1.5.0-rc0
Fix Version/s: 1.5.0-rc2, 1.5.0

Type: Bug Priority: Unknown
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Binding Changes: Not Needed

 Description   

Error handling of _mongocrypt_transform_binary_in_bson does not free a possibly partially constructed BSON document for the final result. Example in mongocrypt-ctx-encrypt.c:

      bson_init (&converted);
      if (!_mongocrypt_transform_binary_in_bson (
             _replace_marking_with_ciphertext,
             &ctx->kb,
             TRAVERSE_MATCH_MARKING,
             &iter,
             &converted,
             ctx->status)) {
         return _mongocrypt_ctx_fail (ctx);
      }

This is missing a call to bson_destroy (&converted) on error.



 Comments   
Comment by Githook User [ 03/Jun/22 ]

Author:

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

Message: MONGOCRYPT-438 fix possible leaks on encryption and decryption (#357)
Branch: master
https://github.com/mongodb/libmongocrypt/commit/95d71916691ea748fe93693771dedbff708a3c8e

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