diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-03-01 18:12:18 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-03-01 18:12:18 +0100 |
commit | 7219603be3009d519b59aa60c15db003edfcca32 (patch) | |
tree | 066f9156622ae514428ba8781ce4852987fa340f /src | |
parent | 8d9b1082615e4d26a3b7f85689d9b17aed5cd756 (diff) | |
download | gnunet-7219603be3009d519b59aa60c15db003edfcca32.tar.gz gnunet-7219603be3009d519b59aa60c15db003edfcca32.zip |
-coverity bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 1 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord_crypto.c | 44 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 20 | ||||
-rw-r--r-- | src/util/dnsstub.c | 2 |
4 files changed, 36 insertions, 31 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 59b7d691c..72b228f33 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -2304,6 +2304,7 @@ handle_gns_resolution_result (void *cls, | |||
2304 | rd_count, | 2304 | rd_count, |
2305 | rd)) | 2305 | rd)) |
2306 | return; | 2306 | return; |
2307 | break; | ||
2307 | default: | 2308 | default: |
2308 | if (GNUNET_YES != GNUNET_GNSRECORD_is_critical (rd[0].record_type)) | 2309 | if (GNUNET_YES != GNUNET_GNSRECORD_is_critical (rd[0].record_type)) |
2309 | return; | 2310 | return; |
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c index 01c47a8e0..688e639f3 100644 --- a/src/gnsrecord/gnsrecord_crypto.c +++ b/src/gnsrecord/gnsrecord_crypto.c | |||
@@ -280,12 +280,12 @@ block_create_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
280 | label, | 280 | label, |
281 | ecblock->expiration_time.abs_value_us__, | 281 | ecblock->expiration_time.abs_value_us__, |
282 | pkey); | 282 | pkey); |
283 | GNUNET_break (payload_len == | 283 | GNUNET_assert (payload_len == |
284 | ecdsa_symmetric_encrypt (payload, | 284 | ecdsa_symmetric_encrypt (payload, |
285 | payload_len, | 285 | payload_len, |
286 | skey, | 286 | skey, |
287 | ctr, | 287 | ctr, |
288 | &ecblock[1])); | 288 | &ecblock[1])); |
289 | GNUNET_memcpy (&gnr_block[1], &ecblock[1], payload_len); | 289 | GNUNET_memcpy (&gnr_block[1], &ecblock[1], payload_len); |
290 | } | 290 | } |
291 | if (GNUNET_OK != | 291 | if (GNUNET_OK != |
@@ -296,8 +296,10 @@ block_create_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
296 | GNUNET_break (0); | 296 | GNUNET_break (0); |
297 | GNUNET_free (*block); | 297 | GNUNET_free (*block); |
298 | GNUNET_free (dkey); | 298 | GNUNET_free (dkey); |
299 | GNUNET_free (gnr_block); | ||
299 | return GNUNET_SYSERR; | 300 | return GNUNET_SYSERR; |
300 | } | 301 | } |
302 | GNUNET_free (gnr_block); | ||
301 | GNUNET_free (dkey); | 303 | GNUNET_free (dkey); |
302 | return GNUNET_OK; | 304 | return GNUNET_OK; |
303 | } | 305 | } |
@@ -411,12 +413,12 @@ block_create_eddsa (const struct GNUNET_CRYPTO_EddsaPrivateKey *key, | |||
411 | label, | 413 | label, |
412 | edblock->expiration_time.abs_value_us__, | 414 | edblock->expiration_time.abs_value_us__, |
413 | pkey); | 415 | pkey); |
414 | GNUNET_break (GNUNET_OK == | 416 | GNUNET_assert (GNUNET_OK == |
415 | eddsa_symmetric_encrypt (payload, | 417 | eddsa_symmetric_encrypt (payload, |
416 | payload_len, | 418 | payload_len, |
417 | skey, | 419 | skey, |
418 | nonce, | 420 | nonce, |
419 | &edblock[1])); | 421 | &edblock[1])); |
420 | GNUNET_memcpy (&gnr_block[1], &edblock[1], | 422 | GNUNET_memcpy (&gnr_block[1], &edblock[1], |
421 | payload_len + crypto_secretbox_MACBYTES); | 423 | payload_len + crypto_secretbox_MACBYTES); |
422 | 424 | ||
@@ -646,10 +648,10 @@ block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block, | |||
646 | char payload[payload_len]; | 648 | char payload[payload_len]; |
647 | unsigned int rd_count; | 649 | unsigned int rd_count; |
648 | 650 | ||
649 | GNUNET_break (payload_len == | 651 | GNUNET_assert (payload_len == |
650 | ecdsa_symmetric_decrypt (&block[1], payload_len, | 652 | ecdsa_symmetric_decrypt (&block[1], payload_len, |
651 | key, ctr, | 653 | key, ctr, |
652 | payload)); | 654 | payload)); |
653 | rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len, | 655 | rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len, |
654 | payload); | 656 | payload); |
655 | if (rd_count > 2048) | 657 | if (rd_count > 2048) |
@@ -771,10 +773,10 @@ block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block, | |||
771 | char payload[payload_len]; | 773 | char payload[payload_len]; |
772 | unsigned int rd_count; | 774 | unsigned int rd_count; |
773 | 775 | ||
774 | GNUNET_break (GNUNET_OK == | 776 | GNUNET_assert (GNUNET_OK == |
775 | eddsa_symmetric_decrypt (&block[1], payload_len, | 777 | eddsa_symmetric_decrypt (&block[1], payload_len, |
776 | key, nonce, | 778 | key, nonce, |
777 | payload)); | 779 | payload)); |
778 | payload_len -= crypto_secretbox_MACBYTES; | 780 | payload_len -= crypto_secretbox_MACBYTES; |
779 | rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len, | 781 | rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len, |
780 | payload); | 782 | payload); |
@@ -904,7 +906,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
904 | proc_cls); | 906 | proc_cls); |
905 | break; | 907 | break; |
906 | default: | 908 | default: |
907 | return GNUNET_SYSERR; | 909 | res = GNUNET_SYSERR; |
908 | } | 910 | } |
909 | GNUNET_free (norm_label); | 911 | GNUNET_free (norm_label); |
910 | return res; | 912 | return res; |
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index 9da5bd920..3298168f4 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -264,16 +264,18 @@ GNUNET_GNSRECORD_identity_from_data (const char *data, | |||
264 | { | 264 | { |
265 | if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type)) | 265 | if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type)) |
266 | return GNUNET_SYSERR; | 266 | return GNUNET_SYSERR; |
267 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) | ||
268 | return GNUNET_SYSERR; | ||
269 | switch (type) | 267 | switch (type) |
270 | { | 268 | { |
271 | case GNUNET_GNSRECORD_TYPE_PKEY: | 269 | case GNUNET_GNSRECORD_TYPE_PKEY: |
272 | memcpy (&key->ecdsa_key, data, data_size); | 270 | if (data_size > sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) |
273 | break; | 271 | return GNUNET_SYSERR; |
274 | case GNUNET_GNSRECORD_TYPE_EDKEY: | 272 | memcpy (&key->ecdsa_key, data, data_size); |
275 | memcpy (&key->eddsa_key, data, data_size); | 273 | break; |
276 | break; | 274 | case GNUNET_GNSRECORD_TYPE_EDKEY: |
275 | if (data_size > sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)) | ||
276 | return GNUNET_SYSERR; | ||
277 | memcpy (&key->eddsa_key, data, data_size); | ||
278 | break; | ||
277 | default: | 279 | default: |
278 | return GNUNET_NO; | 280 | return GNUNET_NO; |
279 | } | 281 | } |
@@ -296,7 +298,7 @@ GNUNET_GNSRECORD_data_from_identity (const struct | |||
296 | if (0 == *data_size) | 298 | if (0 == *data_size) |
297 | return GNUNET_SYSERR; | 299 | return GNUNET_SYSERR; |
298 | tmp = GNUNET_malloc (*data_size); | 300 | tmp = GNUNET_malloc (*data_size); |
299 | memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size); | 301 | memcpy (tmp, ((char*) key) + sizeof (key->type), *data_size); |
300 | *data = tmp; | 302 | *data = tmp; |
301 | return GNUNET_OK; | 303 | return GNUNET_OK; |
302 | } | 304 | } |
diff --git a/src/util/dnsstub.c b/src/util/dnsstub.c index dbdedec24..90c6d16b7 100644 --- a/src/util/dnsstub.c +++ b/src/util/dnsstub.c | |||
@@ -351,7 +351,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs, | |||
351 | 351 | ||
352 | if (0 == memcmp (&v6->sin6_addr, | 352 | if (0 == memcmp (&v6->sin6_addr, |
353 | &ds_v6->sin6_addr, | 353 | &ds_v6->sin6_addr, |
354 | expectedlen) && | 354 | sizeof (v6->sin6_addr)) && |
355 | (v6->sin6_port == ds_v6->sin6_port)) | 355 | (v6->sin6_port == ds_v6->sin6_port)) |
356 | { | 356 | { |
357 | found = GNUNET_YES; | 357 | found = GNUNET_YES; |