diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-05-15 20:20:48 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-05-15 20:20:48 +0200 |
commit | 6d40171315d344d8a62d611df200d43f1fefc238 (patch) | |
tree | fb6317bccbda0a259718eaf085431ec30f91f9b4 /src | |
parent | 05dc002ec4f5396b5633fcf686cd4cd2d06ae776 (diff) | |
download | gnunet-6d40171315d344d8a62d611df200d43f1fefc238.tar.gz gnunet-6d40171315d344d8a62d611df200d43f1fefc238.zip |
-coverity: handle invalid key length
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 12 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_pabc.c | 1 | ||||
-rw-r--r-- | src/revocation/gnunet-revocation.c | 8 | ||||
-rw-r--r-- | src/revocation/revocation_api.c | 5 |
4 files changed, 18 insertions, 8 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 784a6ee6d..958bf2e94 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1764,8 +1764,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1764 | /** | 1764 | /** |
1765 | * Records other than GNS2DNS not allowed | 1765 | * Records other than GNS2DNS not allowed |
1766 | */ | 1766 | */ |
1767 | if (NULL != ns) | 1767 | GNUNET_free (ns); |
1768 | GNUNET_free (ns); | 1768 | GNUNET_free (ac); |
1769 | return GNUNET_SYSERR; | 1769 | return GNUNET_SYSERR; |
1770 | } | 1770 | } |
1771 | off = 0; | 1771 | off = 0; |
@@ -1777,10 +1777,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1777 | (NULL == ip)) | 1777 | (NULL == ip)) |
1778 | { | 1778 | { |
1779 | GNUNET_break_op (0); | 1779 | GNUNET_break_op (0); |
1780 | if (NULL != n) | 1780 | GNUNET_free (n); |
1781 | GNUNET_free (n); | 1781 | GNUNET_free (ip); |
1782 | if (NULL != ip) | ||
1783 | GNUNET_free (ip); | ||
1784 | continue; | 1782 | continue; |
1785 | } | 1783 | } |
1786 | 1784 | ||
@@ -1789,6 +1787,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh, | |||
1789 | if (off != rd[i].data_size) | 1787 | if (off != rd[i].data_size) |
1790 | { | 1788 | { |
1791 | GNUNET_break_op (0); | 1789 | GNUNET_break_op (0); |
1790 | GNUNET_free (n); | ||
1791 | GNUNET_free (ip); | ||
1792 | continue; | 1792 | continue; |
1793 | } | 1793 | } |
1794 | /* resolve 'ip' to determine the IP(s) of the DNS | 1794 | /* resolve 'ip' to determine the IP(s) of the DNS |
diff --git a/src/reclaim/plugin_rest_pabc.c b/src/reclaim/plugin_rest_pabc.c index a0551f215..4b7d21df3 100644 --- a/src/reclaim/plugin_rest_pabc.c +++ b/src/reclaim/plugin_rest_pabc.c | |||
@@ -282,6 +282,7 @@ set_attributes_from_idtoken (const struct pabc_context *ctx, | |||
282 | "Failed to set attribute `%s'.\n", key); | 282 | "Failed to set attribute `%s'.\n", key); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | GNUNET_free (jwt_string); | ||
285 | return PABC_OK; | 286 | return PABC_OK; |
286 | } | 287 | } |
287 | 288 | ||
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index 99fecdd35..a7f96385c 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -343,7 +343,13 @@ ego_callback (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
343 | GNUNET_DISK_fn_read (filename, proof_of_work, | 343 | GNUNET_DISK_fn_read (filename, proof_of_work, |
344 | GNUNET_REVOCATION_MAX_PROOF_SIZE)))) | 344 | GNUNET_REVOCATION_MAX_PROOF_SIZE)))) |
345 | { | 345 | { |
346 | size_t ksize = GNUNET_IDENTITY_key_get_length (&key); | 346 | ssize_t ksize = GNUNET_IDENTITY_key_get_length (&key); |
347 | if (0 > ksize) | ||
348 | { | ||
349 | fprintf (stderr, | ||
350 | _ ("Error: Key is invalid\n")); | ||
351 | return; | ||
352 | } | ||
347 | if (((psize - sizeof (*proof_of_work)) < ksize) || // Key too small | 353 | if (((psize - sizeof (*proof_of_work)) < ksize) || // Key too small |
348 | (0 != memcmp (&proof_of_work[1], &key, ksize))) // Keys do not match | 354 | (0 != memcmp (&proof_of_work[1], &key, ksize))) // Keys do not match |
349 | { | 355 | { |
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index e2f871c23..f2b95bafa 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -707,6 +707,7 @@ GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc) | |||
707 | unsigned int zeros; | 707 | unsigned int zeros; |
708 | int ret; | 708 | int ret; |
709 | uint64_t pow_nbo; | 709 | uint64_t pow_nbo; |
710 | ssize_t ksize; | ||
710 | 711 | ||
711 | pc->current_pow++; | 712 | pc->current_pow++; |
712 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &(pc->pow[1]); | 713 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &(pc->pow[1]); |
@@ -722,9 +723,11 @@ GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc) | |||
722 | GNUNET_memcpy (&buf[sizeof(uint64_t)], | 723 | GNUNET_memcpy (&buf[sizeof(uint64_t)], |
723 | &pc->pow->timestamp, | 724 | &pc->pow->timestamp, |
724 | sizeof (uint64_t)); | 725 | sizeof (uint64_t)); |
726 | ksize = GNUNET_IDENTITY_key_get_length (pk); | ||
727 | GNUNET_assert (0 < ksize); | ||
725 | GNUNET_memcpy (&buf[sizeof(uint64_t) * 2], | 728 | GNUNET_memcpy (&buf[sizeof(uint64_t) * 2], |
726 | pk, | 729 | pk, |
727 | GNUNET_IDENTITY_key_get_length (pk)); | 730 | ksize); |
728 | GNUNET_CRYPTO_pow_hash (&salt, | 731 | GNUNET_CRYPTO_pow_hash (&salt, |
729 | buf, | 732 | buf, |
730 | sizeof(buf), | 733 | sizeof(buf), |