[MONGOCRYPT-14] Inconsistent about taking string length Created: 13/Apr/19  Updated: 28/Oct/23  Resolved: 19/Apr/19

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

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

Epic Link: Build libmongocrypt library

 Description   

Some functions take a string length:

MONGOCRYPT_EXPORT
bool
mongocrypt_ctx_setopt_masterkey_aws (mongocrypt_ctx_t *ctx,
                                     const char *region,
                                     uint32_t region_len,
                                     const char *cmk,
                                     uint32_t cmk_len);

This enables drivers to pass non NULL terminated strings. But others don't:

MONGOCRYPT_EXPORT
bool
mongocrypt_setopt_kms_provider_aws (mongocrypt_t *crypt,
                                    const char *aws_access_key_id,
                                    const char *aws_secret_access_key);

As per discussion, let's change these methods so that they take a char*-len pair, but allow the length to be -1 to indicate NULL-terminated strings.  This gives us a better safety guarantee while allowing more flexibility for drivers.



 Comments   
Comment by Githook User [ 19/Apr/19 ]

Author:

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

Message: CDRIVER-3083 accept lens for all strings

But make it optional. -1 indicates the string is NULL terminated.
This is consistent with libbson.
Branch: master
https://github.com/10gen/libmongocrypt/commit/40b2005f73741a3fc9971ff1a1a42414be1171f6

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