@@ -340,15 +340,18 @@ _state_need_mongo_collinfo (_state_machine_t *state_machine, bson_error_t *error
340
340
goto fail ;
341
341
}
342
342
343
- /* 2. Return the first result (if any) with mongocrypt_ctx_mongo_feed or
343
+ /* 2. Return all results (if any) with mongocrypt_ctx_mongo_feed or
344
344
* proceed to the next step if nothing was returned. */
345
- if (mongoc_cursor_next (cursor , & collinfo_bson )) {
345
+ while (mongoc_cursor_next (cursor , & collinfo_bson )) {
346
346
collinfo_bin = mongocrypt_binary_new_from_data ((uint8_t * ) bson_get_data (collinfo_bson ), collinfo_bson -> len );
347
347
if (!mongocrypt_ctx_mongo_feed (state_machine -> ctx , collinfo_bin )) {
348
348
_ctx_check_error (state_machine -> ctx , error , true);
349
349
goto fail ;
350
350
}
351
- } else if (mongoc_cursor_error (cursor , error )) {
351
+ mongocrypt_binary_destroy (collinfo_bin );
352
+ collinfo_bin = NULL ;
353
+ }
354
+ if (mongoc_cursor_error (cursor , error )) {
352
355
goto fail ;
353
356
}
354
357
@@ -1395,6 +1398,10 @@ _mongoc_crypt_new (const bson_t *kms_providers,
1395
1398
crypt -> kmsid_to_tlsopts = mcd_mapof_kmsid_to_tlsopts_new ();
1396
1399
crypt -> handle = mongocrypt_new ();
1397
1400
mongocrypt_setopt_retry_kms (crypt -> handle , true);
1401
+ if (!mongocrypt_setopt_enable_multiple_collinfo (crypt -> handle )) {
1402
+ _crypt_check_error (crypt -> handle , error , true);
1403
+ goto fail ;
1404
+ }
1398
1405
1399
1406
// Stash away a copy of the user's kmsProviders in case we need to lazily
1400
1407
// load credentials.
0 commit comments