@@ -97,10 +97,8 @@ static void drive_ctx(mongocrypt_ctx_t *ctx, const uint8_t **data, size_t *remai
9797 if (feed_data ) {
9898 mongocrypt_binary_t * bin =
9999 mongocrypt_binary_new_from_data ((uint8_t * )feed_data , (uint32_t )feed_len );
100- if (bin ) {
101- mongocrypt_ctx_mongo_feed (ctx , bin );
102- mongocrypt_binary_destroy (bin );
103- }
100+ mongocrypt_ctx_mongo_feed (ctx , bin );
101+ mongocrypt_binary_destroy (bin );
104102 }
105103 }
106104 mongocrypt_ctx_mongo_done (ctx );
@@ -123,19 +121,15 @@ static void drive_ctx(mongocrypt_ctx_t *ctx, const uint8_t **data, size_t *remai
123121 if (feed_data ) {
124122 mongocrypt_binary_t * bin =
125123 mongocrypt_binary_new_from_data ((uint8_t * )feed_data , (uint32_t )feed_len );
126- if (bin ) {
127- mongocrypt_ctx_provide_kms_providers (ctx , bin );
128- mongocrypt_binary_destroy (bin );
129- }
124+ mongocrypt_ctx_provide_kms_providers (ctx , bin );
125+ mongocrypt_binary_destroy (bin );
130126 }
131127 } else {
132128 bson_t empty = BSON_INITIALIZER ;
133129 mongocrypt_binary_t * bin =
134130 mongocrypt_binary_new_from_data ((uint8_t * )bson_get_data (& empty ), (uint32_t )empty .len );
135- if (bin ) {
136- mongocrypt_ctx_provide_kms_providers (ctx , bin );
137- mongocrypt_binary_destroy (bin );
138- }
131+ mongocrypt_ctx_provide_kms_providers (ctx , bin );
132+ mongocrypt_binary_destroy (bin );
139133 }
140134 break ;
141135 }
@@ -159,12 +153,10 @@ static void drive_ctx(mongocrypt_ctx_t *ctx, const uint8_t **data, size_t *remai
159153 if (feed_data ) {
160154 mongocrypt_binary_t * bin =
161155 mongocrypt_binary_new_from_data ((uint8_t * )feed_data , (uint32_t )feed_len );
162- if (bin ) {
163- bool ok = mongocrypt_kms_ctx_feed (kms_ctx , bin );
164- mongocrypt_binary_destroy (bin );
165- if (!ok ) {
166- return ;
167- }
156+ bool ok = mongocrypt_kms_ctx_feed (kms_ctx , bin );
157+ mongocrypt_binary_destroy (bin );
158+ if (!ok ) {
159+ return ;
168160 }
169161 }
170162 }
@@ -213,10 +205,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
213205 uint8_t local_key [FUZZ_KEY_LEN ];
214206 memset (local_key , 0xAB , FUZZ_KEY_LEN );
215207 mongocrypt_binary_t * key_bin = mongocrypt_binary_new_from_data (local_key , FUZZ_KEY_LEN );
216- if (!key_bin ) {
217- mongocrypt_destroy (crypt );
218- return 0 ;
219- }
220208 mongocrypt_setopt_kms_provider_local (crypt , key_bin );
221209 mongocrypt_binary_destroy (key_bin );
222210
@@ -234,10 +222,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
234222 bson_t * kmip_doc = BCON_NEW ("kmip" , "{" , "endpoint" , "localhost:5696" , "}" );
235223 mongocrypt_binary_t * kmip_bin =
236224 mongocrypt_binary_new_from_data ((uint8_t * )bson_get_data (kmip_doc ), (uint32_t )kmip_doc -> len );
237- if (kmip_bin ) {
238- mongocrypt_setopt_kms_providers (crypt , kmip_bin );
239- mongocrypt_binary_destroy (kmip_bin );
240- }
225+ mongocrypt_setopt_kms_providers (crypt , kmip_bin );
226+ mongocrypt_binary_destroy (kmip_bin );
241227 bson_destroy (kmip_doc );
242228 }
243229
@@ -278,10 +264,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
278264 uint8_t key_id [16 ];
279265 memset (key_id , 0x61 , sizeof (key_id )); /* matches "YWFhYWFhYWFhYWFhYWFhYQ==" */
280266 mongocrypt_binary_t * kid_bin = mongocrypt_binary_new_from_data (key_id , sizeof (key_id ));
281- if (kid_bin ) {
282- mongocrypt_ctx_setopt_key_id (ctx , kid_bin );
283- mongocrypt_binary_destroy (kid_bin );
284- }
267+ mongocrypt_ctx_setopt_key_id (ctx , kid_bin );
268+ mongocrypt_binary_destroy (kid_bin );
285269 mongocrypt_ctx_setopt_algorithm (ctx , "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" , -1 );
286270 if (input_bin ) {
287271 init_ok = mongocrypt_ctx_explicit_encrypt_init (ctx , input_bin );
@@ -299,10 +283,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
299283 bson_t * kek = BCON_NEW ("provider" , "local" );
300284 mongocrypt_binary_t * kek_bin =
301285 mongocrypt_binary_new_from_data ((uint8_t * )bson_get_data (kek ), (uint32_t )kek -> len );
302- if (kek_bin ) {
303- mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
304- mongocrypt_binary_destroy (kek_bin );
305- }
286+ mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
287+ mongocrypt_binary_destroy (kek_bin );
306288 bson_destroy (kek );
307289 init_ok = mongocrypt_ctx_datakey_init (ctx );
308290 break ;
@@ -318,10 +300,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
318300 uint8_t key_id [16 ];
319301 memset (key_id , 0x61 , sizeof (key_id ));
320302 mongocrypt_binary_t * kid_bin = mongocrypt_binary_new_from_data (key_id , sizeof (key_id ));
321- if (kid_bin ) {
322- mongocrypt_ctx_setopt_key_id (ctx , kid_bin );
323- mongocrypt_binary_destroy (kid_bin );
324- }
303+ mongocrypt_ctx_setopt_key_id (ctx , kid_bin );
304+ mongocrypt_binary_destroy (kid_bin );
325305 mongocrypt_ctx_setopt_query_type (ctx , MONGOCRYPT_QUERY_TYPE_RANGE_STR , -1 );
326306 if (input_bin ) {
327307 init_ok = mongocrypt_ctx_explicit_encrypt_expression_init (ctx , input_bin );
@@ -336,10 +316,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
336316 bson_t * kek = BCON_NEW ("provider" , "aws" , "region" , "us-east-1" , "key" , "arn:aws:kms:us-east-1:0:key/fuzz" );
337317 mongocrypt_binary_t * kek_bin =
338318 mongocrypt_binary_new_from_data ((uint8_t * )bson_get_data (kek ), (uint32_t )kek -> len );
339- if (kek_bin ) {
340- mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
341- mongocrypt_binary_destroy (kek_bin );
342- }
319+ mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
320+ mongocrypt_binary_destroy (kek_bin );
343321 bson_destroy (kek );
344322 init_ok = mongocrypt_ctx_datakey_init (ctx );
345323 break ;
@@ -352,10 +330,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
352330 bson_t * kek = BCON_NEW ("provider" , "kmip" );
353331 mongocrypt_binary_t * kek_bin =
354332 mongocrypt_binary_new_from_data ((uint8_t * )bson_get_data (kek ), (uint32_t )kek -> len );
355- if (kek_bin ) {
356- mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
357- mongocrypt_binary_destroy (kek_bin );
358- }
333+ mongocrypt_ctx_setopt_key_encryption_key (ctx , kek_bin );
334+ mongocrypt_binary_destroy (kek_bin );
359335 bson_destroy (kek );
360336 init_ok = mongocrypt_ctx_datakey_init (ctx );
361337 break ;
0 commit comments