[MONGOCRYPT-26] mongocrypt_status_set requires null byte to be included in message_len Created: 09/Aug/19  Updated: 28/Oct/23  Resolved: 16/Oct/19

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

Type: Bug Priority: Minor - P4
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-1925 Add libmongocrypt cypto hooks Closed

 Description   

mongocrypt_status_set requires null byte to be included in message_len, eg in Python this code prints '12' instead of '123':

msg = b"123"
lib.mongocrypt_status_set(
    status, lib.MONGOCRYPT_STATUS_ERROR_CLIENT, 1, msg, len(msg) + 1)
msg2 = _to_string(lib.mongocrypt_status_message(status, ffi.NULL))
print(msg2)

Other libmongocrypt functions (like mongocrypt_ctx_setopt_masterkey_aws) don't need the +1 for the null byte so I consider this a bug.



 Comments   
Comment by Githook User [ 16/Oct/19 ]

Author:

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

Message: MONGOCRYPT-167 remove character limit of status message

Also covers MONGOCRYPT-26: document weirdness of extra +1 for string length.
Branch: master
https://github.com/mongodb/libmongocrypt/commit/1bf29a30ced85e903070a7e9d7c1de018546cac5

Comment by Kevin Albertson [ 16/Aug/19 ]

Though unfortunate, changing how mongocrypt_status_set interprets the length would be a breaking change. We'll better document that the length should include the null byte.

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