aboutsummaryrefslogtreecommitdiff
path: root/src/abd
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-01-01 09:15:46 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2022-01-01 09:15:46 +0100
commit2cbb614f694701c4afdab88f58ef7626629e1bc3 (patch)
treec218d78f8284c88361a7e6fc00eacdd22ebfe615 /src/abd
parent9e0d7d411363999bca89f7e7b4e2896b8f6ec931 (diff)
downloadgnunet-2cbb614f694701c4afdab88f58ef7626629e1bc3.tar.gz
gnunet-2cbb614f694701c4afdab88f58ef7626629e1bc3.zip
-coverity
Diffstat (limited to 'src/abd')
-rw-r--r--src/abd/abd_serialization.c4
-rw-r--r--src/abd/delegate_misc.c18
-rw-r--r--src/abd/gnunet-abd.c26
-rw-r--r--src/abd/gnunet-service-abd.c44
-rw-r--r--src/abd/plugin_gnsrecord_abd.c11
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 (
191 off = 0; 191 off = 0;
192 for (i = 0; i < c_count; i++) 192 for (i = 0; i < c_count; i++)
193 { 193 {
194 // c_rec.subject_attribute_len = htonl ((uint32_t) cd[i].subject_attribute_len); 194 c_rec.subject_attribute_len = htonl (cd[i].subject_attribute_len);
195 c_rec.issuer_attribute_len = htonl ((uint32_t) cd[i].issuer_attribute_len); 195 c_rec.issuer_attribute_len = htonl (cd[i].issuer_attribute_len);
196 c_rec.issuer_key = cd[i].issuer_key; 196 c_rec.issuer_key = cd[i].issuer_key;
197 c_rec.subject_key = cd[i].subject_key; 197 c_rec.subject_key = cd[i].subject_key;
198 c_rec.signature = cd[i].signature; 198 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)
143 } 143 }
144 tmp_str[attr_len - 1] = '\0'; 144 tmp_str[attr_len - 1] = '\0';
145 145
146 GNUNET_IDENTITY_public_key_from_string (subject_pkey, 146 if (GNUNET_SYSERR ==
147 &dele->subject_key); 147 GNUNET_IDENTITY_public_key_from_string (subject_pkey,
148 GNUNET_IDENTITY_public_key_from_string (issuer_pkey, 148 &dele->subject_key))
149 &dele->issuer_key); 149 {
150 GNUNET_free (dele);
151 return NULL;
152 }
153 if (GNUNET_SYSERR ==
154 GNUNET_IDENTITY_public_key_from_string (issuer_pkey,
155 &dele->issuer_key))
156 {
157 GNUNET_free (dele);
158 return NULL;
159 }
150 GNUNET_assert (sizeof (struct GNUNET_IDENTITY_Signature) == 160 GNUNET_assert (sizeof (struct GNUNET_IDENTITY_Signature) ==
151 GNUNET_STRINGS_base64_decode (signature, 161 GNUNET_STRINGS_base64_decode (signature,
152 strlen (signature), 162 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
544store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) 544store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
545{ 545{
546 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 546 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
547 struct GNUNET_ABD_Delegate *cred;
548 struct GNUNET_IDENTITY_PublicKey zone_pubkey;
549 char *subject_pubkey_str;
550 char *zone_pubkey_str;
547 551
548 el = NULL; 552 el = NULL;
549 553
@@ -562,17 +566,23 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
562 if (GNUNET_GNSRECORD_TYPE_DELEGATE == type) 566 if (GNUNET_GNSRECORD_TYPE_DELEGATE == type)
563 { 567 {
564 // Parse import 568 // Parse import
565 struct GNUNET_ABD_Delegate *cred;
566 cred = GNUNET_ABD_delegate_from_string (import); 569 cred = GNUNET_ABD_delegate_from_string (import);
567 570
571 if (NULL == cred)
572 {
573 fprintf (stderr,
574 "%s is not a valid credential\n", import);
575 GNUNET_SCHEDULER_shutdown();
576 return;
577 }
578
568 // Get import subject public key string 579 // Get import subject public key string
569 char *subject_pubkey_str = 580 subject_pubkey_str =
570 GNUNET_IDENTITY_public_key_to_string (&cred->subject_key); 581 GNUNET_IDENTITY_public_key_to_string (&cred->subject_key);
571 582
572 // Get zone public key string 583 // Get zone public key string
573 struct GNUNET_IDENTITY_PublicKey zone_pubkey;
574 GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey); 584 GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
575 char *zone_pubkey_str = 585 zone_pubkey_str =
576 GNUNET_IDENTITY_public_key_to_string (&zone_pubkey); 586 GNUNET_IDENTITY_public_key_to_string (&zone_pubkey);
577 587
578 // Check if the subject key in the signed import matches the zone's key it is issued to 588 // 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)
580 { 590 {
581 fprintf (stderr, 591 fprintf (stderr,
582 "Import signed delegate does not match this ego's public key.\n"); 592 "Import signed delegate does not match this ego's public key.\n");
593 GNUNET_free (cred);
583 GNUNET_SCHEDULER_shutdown (); 594 GNUNET_SCHEDULER_shutdown ();
584 return; 595 return;
585 } 596 }
@@ -691,6 +702,13 @@ sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
691 // work on keys 702 // work on keys
692 privkey = GNUNET_IDENTITY_ego_get_private_key (ego); 703 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
693 704
705 if (NULL == subject_pubkey_str)
706 {
707 fprintf (stderr,
708 "Subject pubkey not given\n");
709 GNUNET_SCHEDULER_shutdown ();
710 return;
711 }
694 if (GNUNET_OK != 712 if (GNUNET_OK !=
695 GNUNET_IDENTITY_public_key_from_string (subject_pubkey_str, 713 GNUNET_IDENTITY_public_key_from_string (subject_pubkey_str,
696 &subject_pkey)) 714 &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
512 size, 512 size,
513 (char *) &rmsg[1])); 513 (char *) &rmsg[1]));
514 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env); 514 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
515
516 GNUNET_free (dd);
515} 517}
516 518
517 519
@@ -740,12 +742,13 @@ forward_resolution (void *cls,
740 uint32_t rd_count, 742 uint32_t rd_count,
741 const struct GNUNET_GNSRECORD_Data *rd) 743 const struct GNUNET_GNSRECORD_Data *rd)
742{ 744{
743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
744
745 struct VerifyRequestHandle *vrh; 745 struct VerifyRequestHandle *vrh;
746 struct DelegationSetQueueEntry *current_set; 746 struct DelegationSetQueueEntry *current_set;
747 struct DelegationSetQueueEntry *ds_entry; 747 struct DelegationSetQueueEntry *ds_entry;
748 struct DelegationQueueEntry *dq_entry; 748 struct DelegationQueueEntry *dq_entry;
749 struct GNUNET_ABD_Delegate *del;
750
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d entries.\n", rd_count);
749 752
750 current_set = cls; 753 current_set = cls;
751 // set handle to NULL (as el = NULL) 754 // set handle to NULL (as el = NULL)
@@ -760,9 +763,11 @@ forward_resolution (void *cls,
760 continue; 763 continue;
761 764
762 // Start deserialize into Delegate 765 // Start deserialize into Delegate
763 struct GNUNET_ABD_Delegate *del;
764 del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size); 766 del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
765 767
768 if (NULL == del)
769 continue;
770
766 // Start: Create DQ Entry 771 // Start: Create DQ Entry
767 dq_entry = GNUNET_new (struct DelegationQueueEntry); 772 dq_entry = GNUNET_new (struct DelegationQueueEntry);
768 // AND delegations are not possible, only 1 solution 773 // AND delegations are not possible, only 1 solution
@@ -834,6 +839,7 @@ forward_resolution (void *cls,
834 GNUNET_IDENTITY_public_key_to_string ( 839 GNUNET_IDENTITY_public_key_to_string (
835 &del->subject_key), 840 &del->subject_key),
836 del->subject_attribute); 841 del->subject_attribute);
842 GNUNET_free (del);
837 continue; 843 continue;
838 } 844 }
839 else 845 else
@@ -910,6 +916,7 @@ forward_resolution (void *cls,
910 } 916 }
911 917
912 send_lookup_response (vrh); 918 send_lookup_response (vrh);
919 GNUNET_free (del);
913 return; 920 return;
914 } 921 }
915 } 922 }
@@ -936,6 +943,7 @@ forward_resolution (void *cls,
936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
937 "Forward: Found match with above!\n"); 944 "Forward: Found match with above!\n");
938 945
946 GNUNET_free (del);
939 // one node on the path still needs solutions: return 947 // one node on the path still needs solutions: return
940 if (GNUNET_NO == 948 if (GNUNET_NO ==
941 handle_bidirectional_match (ds_entry, del_entry, vrh)) 949 handle_bidirectional_match (ds_entry, del_entry, vrh))
@@ -965,6 +973,7 @@ forward_resolution (void *cls,
965 GNUNET_GNS_LO_DEFAULT, 973 GNUNET_GNS_LO_DEFAULT,
966 &forward_resolution, 974 &forward_resolution,
967 ds_entry); 975 ds_entry);
976 GNUNET_free (del);
968 } 977 }
969 978
970 if (0 == vrh->pending_lookups) 979 if (0 == vrh->pending_lookups)
@@ -1586,34 +1595,29 @@ handle_delegate_collection_cb (void *cls,
1586 const struct GNUNET_GNSRECORD_Data *rd) 1595 const struct GNUNET_GNSRECORD_Data *rd)
1587{ 1596{
1588 struct VerifyRequestHandle *vrh = cls; 1597 struct VerifyRequestHandle *vrh = cls;
1589 struct GNUNET_ABD_Delegate *del;
1590 struct DelegateRecordEntry *del_entry; 1598 struct DelegateRecordEntry *del_entry;
1591 int cred_record_count;
1592 cred_record_count = 0;
1593 vrh->dele_qe = NULL; 1599 vrh->dele_qe = NULL;
1594 1600
1595 for (uint32_t i = 0; i < rd_count; i++) 1601 for (uint32_t i = 0; i < rd_count; i++)
1596 { 1602 {
1597 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type) 1603 if (GNUNET_GNSRECORD_TYPE_DELEGATE != rd[i].record_type)
1598 continue; 1604 continue;
1599 cred_record_count++;
1600 del = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
1601 if (NULL == del)
1602 {
1603 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1604 continue;
1605 }
1606 // only add the entries that are explicitly marked as private 1605 // only add the entries that are explicitly marked as private
1607 // and therefore symbolize the end of a chain 1606 // and therefore symbolize the end of a chain
1608 if (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE) 1607 if (0 == (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE))
1608 continue;
1609 del_entry = GNUNET_new (struct DelegateRecordEntry);
1610 del_entry->delegate = GNUNET_ABD_delegate_deserialize (rd[i].data, rd[i].data_size);
1611 if (NULL == del_entry->delegate)
1609 { 1612 {
1610 del_entry = GNUNET_new (struct DelegateRecordEntry); 1613 GNUNET_free (del_entry);
1611 del_entry->delegate = del; 1614 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid delegate found\n");
1612 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head, 1615 continue;
1613 vrh->del_chain_tail,
1614 del_entry);
1615 vrh->del_chain_size++;
1616 } 1616 }
1617 GNUNET_CONTAINER_DLL_insert_tail (vrh->del_chain_head,
1618 vrh->del_chain_tail,
1619 del_entry);
1620 vrh->del_chain_size++;
1617 } 1621 }
1618 1622
1619 delegate_collection_finished (vrh); 1623 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,
207 matches = sscanf (token, "%s %s", subject_pkey, attr_str); 207 matches = sscanf (token, "%s %s", subject_pkey, attr_str);
208 208
209 // sets the public key for the set entry 209 // sets the public key for the set entry
210 GNUNET_IDENTITY_public_key_from_string (subject_pkey, 210 if (GNUNET_SYSERR ==
211 &set[i].subject_key); 211 GNUNET_IDENTITY_public_key_from_string (subject_pkey,
212 &set[i].subject_key))
213 {
214 GNUNET_free (tmp_str);
215 return GNUNET_SYSERR;
216 }
212 217
213 // If not just key, also set subject attribute (Not A.a <- B but A.a <- B.b) 218 // If not just key, also set subject attribute (Not A.a <- B but A.a <- B.b)
214 if (2 == matches) 219 if (2 == matches)
@@ -252,7 +257,7 @@ abd_string_to_value (void *cls,
252 cred = GNUNET_ABD_delegate_from_string (s); 257 cred = GNUNET_ABD_delegate_from_string (s);
253 258
254 *data_size = GNUNET_ABD_delegate_serialize (cred, (char **) data); 259 *data_size = GNUNET_ABD_delegate_serialize (cred, (char **) data);
255 260 GNUNET_free (cred);
256 return GNUNET_OK; 261 return GNUNET_OK;
257 } 262 }
258 default: 263 default: