[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -coverity
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -coverity |
Date: |
Sat, 01 Jan 2022 09:15:52 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 2cbb614f6 -coverity
2cbb614f6 is described below
commit 2cbb614f694701c4afdab88f58ef7626629e1bc3
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Jan 1 09:15:46 2022 +0100
-coverity
---
src/abd/abd_serialization.c | 4 ++--
src/abd/delegate_misc.c | 18 +++++++++++++----
src/abd/gnunet-abd.c | 26 +++++++++++++++++++++----
src/abd/gnunet-service-abd.c | 44 +++++++++++++++++++++++-------------------
src/abd/plugin_gnsrecord_abd.c | 11 ++++++++---
5 files changed, 70 insertions(+), 33 deletions(-)
diff --git a/src/abd/abd_serialization.c b/src/abd/abd_serialization.c
index 4c219d791..2ed24ff2f 100644
--- a/src/abd/abd_serialization.c
+++ b/src/abd/abd_serialization.c
@@ -191,8 +191,8 @@ GNUNET_ABD_delegates_serialize (
off = 0;
for (i = 0; i < c_count; i++)
{
- // c_rec.subject_attribute_len = htonl ((uint32_t)
cd[i].subject_attribute_len);
- c_rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len);
+ c_rec.subject_attribute_len = htonl (cd[i].subject_attribute_len);
+ c_rec.issuer_attribute_len = htonl (cd[i].issuer_attribute_len);
c_rec.issuer_key = cd[i].issuer_key;
c_rec.subject_key = cd[i].subject_key;
c_rec.signature = cd[i].signature;
diff --git a/src/abd/delegate_misc.c b/src/abd/delegate_misc.c
index d67b40088..0c5520d52 100644
--- a/src/abd/delegate_misc.c
+++ b/src/abd/delegate_misc.c
@@ -143,10 +143,20 @@ GNUNET_ABD_delegate_from_string (const char *s)
}
tmp_str[attr_len - 1] = '\0';
- GNUNET_IDENTITY_public_key_from_string (subject_pkey,
- &dele->subject_key);
- GNUNET_IDENTITY_public_key_from_string (issuer_pkey,
- &dele->issuer_key);
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_public_key_from_string (subject_pkey,
+ &dele->subject_key))
+ {
+ GNUNET_free (dele);
+ return NULL;
+ }
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_public_key_from_string (issuer_pkey,
+ &dele->issuer_key))
+ {
+ GNUNET_free (dele);
+ return NULL;
+ }
GNUNET_assert (sizeof (struct GNUNET_IDENTITY_Signature) ==
GNUNET_STRINGS_base64_decode (signature,
strlen (signature),
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c
index 17671273c..cf3733abd 100644
--- a/src/abd/gnunet-abd.c
+++ b/src/abd/gnunet-abd.c
@@ -544,6 +544,10 @@ static void
store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ struct GNUNET_ABD_Delegate *cred;
+ struct GNUNET_IDENTITY_PublicKey zone_pubkey;
+ char *subject_pubkey_str;
+ char *zone_pubkey_str;
el = NULL;
@@ -562,17 +566,23 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
if (GNUNET_GNSRECORD_TYPE_DELEGATE == type)
{
// Parse import
- struct GNUNET_ABD_Delegate *cred;
cred = GNUNET_ABD_delegate_from_string (import);
+ if (NULL == cred)
+ {
+ fprintf (stderr,
+ "%s is not a valid credential\n", import);
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
+
// Get import subject public key string
- char *subject_pubkey_str =
+ subject_pubkey_str =
GNUNET_IDENTITY_public_key_to_string (&cred->subject_key);
// Get zone public key string
- struct GNUNET_IDENTITY_PublicKey zone_pubkey;
GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
- char *zone_pubkey_str =
+ zone_pubkey_str =
GNUNET_IDENTITY_public_key_to_string (&zone_pubkey);
// Check if the subject key in the signed import matches the zone's key it
is issued to
@@ -580,6 +590,7 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
fprintf (stderr,
"Import signed delegate does not match this ego's public
key.\n");
+ GNUNET_free (cred);
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -691,6 +702,13 @@ sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
// work on keys
privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
+ if (NULL == subject_pubkey_str)
+ {
+ fprintf (stderr,
+ "Subject pubkey not given\n");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
if (GNUNET_OK !=
GNUNET_IDENTITY_public_key_from_string (subject_pubkey_str,
&subject_pkey))
diff --git a/src/abd/gnunet-service-abd.c b/src/abd/gnunet-service-abd.c
index 3f9f2f924..407d5bdc3 100644
--- a/src/abd/gnunet-service-abd.c
+++ b/src/abd/gnunet-service-abd.c
@@ -512,6 +512,8 @@ send_intermediate_response (struct VerifyRequestHandle
*vrh, struct
size,
(char *) &rmsg[1]));
GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
+
+ GNUNET_free (dd);
}
@@ -740,12 +742,13 @@ forward_resolution (void *cls,
uint32_t rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
-
struct VerifyRequestHandle *vrh;
struct DelegationSetQueueEntry *current_set;
struct DelegationSetQueueEntry *ds_entry;
struct DelegationQueueEntry *dq_entry;
+ struct GNUNET_ABD_Delegate *del;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
current_set = cls;
// set handle to NULL (as el = NULL)
@@ -760,9 +763,11 @@ forward_resolution (void *cls,
continue;
// Start deserialize into Delegate
- struct GNUNET_ABD_Delegate *del;
del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
+ if (NULL == del)
+ continue;
+
// Start: Create DQ Entry
dq_entry = GNUNET_new (struct DelegationQueueEntry);
// AND delegations are not possible, only 1 solution
@@ -834,6 +839,7 @@ forward_resolution (void *cls,
GNUNET_IDENTITY_public_key_to_string (
&del->subject_key),
del->subject_attribute);
+ GNUNET_free (del);
continue;
}
else
@@ -910,6 +916,7 @@ forward_resolution (void *cls,
}
send_lookup_response (vrh);
+ GNUNET_free (del);
return;
}
}
@@ -936,6 +943,7 @@ forward_resolution (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Forward: Found match with above!\n");
+ GNUNET_free (del);
// one node on the path still needs solutions: return
if (GNUNET_NO ==
handle_bidirectional_match (ds_entry, del_entry, vrh))
@@ -965,6 +973,7 @@ forward_resolution (void *cls,
GNUNET_GNS_LO_DEFAULT,
&forward_resolution,
ds_entry);
+ GNUNET_free (del);
}
if (0 == vrh->pending_lookups)
@@ -1586,34 +1595,29 @@ handle_delegate_collection_cb (void *cls,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct VerifyRequestHandle *vrh = cls;
- struct GNUNET_ABD_Delegate *del;
struct DelegateRecordEntry *del_entry;
- int cred_record_count;
- cred_record_count = 0;
vrh->dele_qe = NULL;
for (uint32_t i = 0; i < rd_count; i++)
{
if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
continue;
- cred_record_count++;
- del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
- if (NULL == del)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
- continue;
- }
// only add the entries that are explicitly marked as private
// and therefore symbolize the end of a chain
- if (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)
+ if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
+ continue;
+ del_entry = GNUNET_new (struct DelegateRecordEntry);
+ del_entry->delegate = GNUNET_ABD_delegate_deserialize (rd[i].data,
rd[i].data_size);
+ if (NULL == del_entry->delegate)
{
- del_entry = GNUNET_new (struct DelegateRecordEntry);
- del_entry->delegate = del;
- GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
- vrh->del_chain_tail,
- del_entry);
- vrh->del_chain_size++;
+ GNUNET_free (del_entry);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
+ continue;
}
+ GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
+ vrh->del_chain_tail,
+ del_entry);
+ vrh->del_chain_size++;
}
delegate_collection_finished (vrh);
diff --git a/src/abd/plugin_gnsrecord_abd.c b/src/abd/plugin_gnsrecord_abd.c
index 24cf6a3aa..7b2f4af5b 100644
--- a/src/abd/plugin_gnsrecord_abd.c
+++ b/src/abd/plugin_gnsrecord_abd.c
@@ -207,8 +207,13 @@ abd_string_to_value (void *cls,
matches = sscanf (token, "%s %s", subject_pkey, attr_str);
// sets the public key for the set entry
- GNUNET_IDENTITY_public_key_from_string (subject_pkey,
- &set[i].subject_key);
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_public_key_from_string (subject_pkey,
+ &set[i].subject_key))
+ {
+ GNUNET_free (tmp_str);
+ return GNUNET_SYSERR;
+ }
// If not just key, also set subject attribute (Not A.a <- B but A.a
<- B.b)
if (2 == matches)
@@ -252,7 +257,7 @@ abd_string_to_value (void *cls,
cred = GNUNET_ABD_delegate_from_string (s);
*data_size = GNUNET_ABD_delegate_serialize (cred, (char **) data);
-
+ GNUNET_free (cred);
return GNUNET_OK;
}
default:
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -coverity,
gnunet <=