Skip to content

Commit 9e2bdaf

Browse files
authored
MONGOCRYPT-432 always initialize out and key_id_out (#1154)
Resolves Coverity issue with CID: 202881. Matches internal documentation of `_mongocrypt_key_broker_decrypted_key_by_name` and `_mongocrypt_key_broker_decrypted_key_by_id`
1 parent c0353cd commit 9e2bdaf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/mongocrypt-key-broker.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,8 @@ bool _mongocrypt_key_broker_decrypted_key_by_id(_mongocrypt_key_broker_t *kb,
10631063
BSON_ASSERT_PARAM(key_id);
10641064
BSON_ASSERT_PARAM(out);
10651065

1066+
_mongocrypt_buffer_init(out);
1067+
10661068
if (kb->state != KB_DONE && kb->state != KB_REQUESTING) {
10671069
return _key_broker_fail_w_msg(kb, "attempting retrieve decrypted key material, but in wrong state");
10681070
}
@@ -1085,6 +1087,9 @@ bool _mongocrypt_key_broker_decrypted_key_by_name(_mongocrypt_key_broker_t *kb,
10851087
BSON_ASSERT_PARAM(out);
10861088
BSON_ASSERT_PARAM(key_id_out);
10871089

1090+
_mongocrypt_buffer_init(out);
1091+
_mongocrypt_buffer_init(key_id_out);
1092+
10881093
// We may be in KB_REQUESTING and need keys after requesting keys for keyAltName
10891094
if (kb->state != KB_DONE && kb->state != KB_REQUESTING) {
10901095
return _key_broker_fail_w_msg(kb, "attempting retrieve decrypted key material, but in wrong state");

0 commit comments

Comments
 (0)