summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-03-01 18:12:18 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2022-03-01 18:12:18 +0100
commit7219603be3009d519b59aa60c15db003edfcca32 (patch)
tree066f9156622ae514428ba8781ce4852987fa340f
parent8d9b1082615e4d26a3b7f85689d9b17aed5cd756 (diff)
-coverity bugs
-rw-r--r--po/POTFILES.in3
-rw-r--r--src/gns/gnunet-service-gns_resolver.c1
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c44
-rw-r--r--src/gnsrecord/gnsrecord_misc.c20
-rw-r--r--src/util/dnsstub.c2
5 files changed, 36 insertions, 34 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d2e44dec1..5c1152e7c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -175,7 +175,6 @@ src/gns/nss/nss_gns_query.c
src/gns/plugin_block_gns.c
src/gns/plugin_gnsrecord_gns.c
src/gns/plugin_rest_gns.c
-src/gns/test.c
src/gnsrecord/gnsrecord.c
src/gnsrecord/gnsrecord_crypto.c
src/gnsrecord/gnsrecord_misc.c
@@ -183,7 +182,6 @@ src/gnsrecord/gnsrecord_serialization.c
src/gnsrecord/gnunet-gnsrecord-tvg.c
src/gnsrecord/json_gnsrecord.c
src/gnsrecord/plugin_gnsrecord_dns.c
-src/gnsrecord/test.c
src/hello/address.c
src/hello/gnunet-hello.c
src/hello/hello-ng.c
@@ -316,7 +314,6 @@ src/reclaim/plugin_rest_reclaim.c
src/reclaim/reclaim_api.c
src/reclaim/reclaim_attribute.c
src/reclaim/reclaim_credential.c
-src/reclaim/test.c
src/regex/gnunet-daemon-regexprofiler.c
src/regex/gnunet-regex-profiler.c
src/regex/gnunet-regex-simulation-profiler.c
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,
rd_count,
rd))
return;
+ break;
default:
if (GNUNET_YES != GNUNET_GNSRECORD_is_critical (rd[0].record_type))
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,
label,
ecblock->expiration_time.abs_value_us__,
pkey);
- GNUNET_break (payload_len ==
- ecdsa_symmetric_encrypt (payload,
- payload_len,
- skey,
- ctr,
- &ecblock[1]));
+ GNUNET_assert (payload_len ==
+ ecdsa_symmetric_encrypt (payload,
+ payload_len,
+ skey,
+ ctr,
+ &ecblock[1]));
GNUNET_memcpy (&gnr_block[1], &ecblock[1], payload_len);
}
if (GNUNET_OK !=
@@ -296,8 +296,10 @@ block_create_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
GNUNET_break (0);
GNUNET_free (*block);
GNUNET_free (dkey);
+ GNUNET_free (gnr_block);
return GNUNET_SYSERR;
}
+ GNUNET_free (gnr_block);
GNUNET_free (dkey);
return GNUNET_OK;
}
@@ -411,12 +413,12 @@ block_create_eddsa (const struct GNUNET_CRYPTO_EddsaPrivateKey *key,
label,
edblock->expiration_time.abs_value_us__,
pkey);
- GNUNET_break (GNUNET_OK ==
- eddsa_symmetric_encrypt (payload,
- payload_len,
- skey,
- nonce,
- &edblock[1]));
+ GNUNET_assert (GNUNET_OK ==
+ eddsa_symmetric_encrypt (payload,
+ payload_len,
+ skey,
+ nonce,
+ &edblock[1]));
GNUNET_memcpy (&gnr_block[1], &edblock[1],
payload_len + crypto_secretbox_MACBYTES);
@@ -646,10 +648,10 @@ block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block,
char payload[payload_len];
unsigned int rd_count;
- GNUNET_break (payload_len ==
- ecdsa_symmetric_decrypt (&block[1], payload_len,
- key, ctr,
- payload));
+ GNUNET_assert (payload_len ==
+ ecdsa_symmetric_decrypt (&block[1], payload_len,
+ key, ctr,
+ payload));
rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len,
payload);
if (rd_count > 2048)
@@ -771,10 +773,10 @@ block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block,
char payload[payload_len];
unsigned int rd_count;
- GNUNET_break (GNUNET_OK ==
- eddsa_symmetric_decrypt (&block[1], payload_len,
- key, nonce,
- payload));
+ GNUNET_assert (GNUNET_OK ==
+ eddsa_symmetric_decrypt (&block[1], payload_len,
+ key, nonce,
+ payload));
payload_len -= crypto_secretbox_MACBYTES;
rd_count = GNUNET_GNSRECORD_records_deserialize_get_size (payload_len,
payload);
@@ -904,7 +906,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
proc_cls);
break;
default:
- return GNUNET_SYSERR;
+ res = GNUNET_SYSERR;
}
GNUNET_free (norm_label);
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,
{
if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type))
return GNUNET_SYSERR;
- if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey))
- return GNUNET_SYSERR;
switch (type)
{
- case GNUNET_GNSRECORD_TYPE_PKEY:
- memcpy (&key->ecdsa_key, data, data_size);
- break;
- case GNUNET_GNSRECORD_TYPE_EDKEY:
- memcpy (&key->eddsa_key, data, data_size);
- break;
+ case GNUNET_GNSRECORD_TYPE_PKEY:
+ if (data_size > sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))
+ return GNUNET_SYSERR;
+ memcpy (&key->ecdsa_key, data, data_size);
+ break;
+ case GNUNET_GNSRECORD_TYPE_EDKEY:
+ if (data_size > sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))
+ return GNUNET_SYSERR;
+ memcpy (&key->eddsa_key, data, data_size);
+ break;
default:
return GNUNET_NO;
}
@@ -296,7 +298,7 @@ GNUNET_GNSRECORD_data_from_identity (const struct
if (0 == *data_size)
return GNUNET_SYSERR;
tmp = GNUNET_malloc (*data_size);
- memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size);
+ memcpy (tmp, ((char*) key) + sizeof (key->type), *data_size);
*data = tmp;
return GNUNET_OK;
}
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,
if (0 == memcmp (&v6->sin6_addr,
&ds_v6->sin6_addr,
- expectedlen) &&
+ sizeof (v6->sin6_addr)) &&
(v6->sin6_port == ds_v6->sin6_port))
{
found = GNUNET_YES;