From 13be935f03ec3265861131c20820752665ab8cca Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Thu, 6 Feb 2020 18:38:02 +0100 Subject: [PATCH] bugfixes --- po/POTFILES.in | 6 +++- src/reclaim-attribute/reclaim_attestation.c | 2 +- src/reclaim-attribute/reclaim_attribute.c | 2 +- src/reclaim/gnunet-reclaim.c | 17 +++++++++++ src/reclaim/gnunet-service-reclaim.c | 7 +++-- src/reclaim/plugin_rest_reclaim.c | 4 ++- src/reclaim/reclaim_api.c | 34 +++++++++++++-------- 7 files changed, 53 insertions(+), 19 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 441d0f91d..f3376d01b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -264,7 +264,9 @@ src/pq/pq_prepare.c src/pq/pq_query_helper.c src/pq/pq_result_helper.c src/pt/gnunet-daemon-pt.c -src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c +src/reclaim-attribute/plugin_reclaim_attestation_jwt.c +src/reclaim-attribute/plugin_reclaim_attribute_basic.c +src/reclaim-attribute/reclaim_attestation.c src/reclaim-attribute/reclaim_attribute.c src/reclaim/gnunet-reclaim.c src/reclaim/gnunet-service-reclaim.c @@ -428,6 +430,7 @@ src/transport/transport_api_offer_hello.c src/util/bandwidth.c src/util/benchmark.c src/util/bio.c +src/util/buffer.c src/util/client.c src/util/common_allocation.c src/util/common_endian.c @@ -464,6 +467,7 @@ src/util/getopt.c src/util/getopt_helpers.c src/util/gnunet-config-diff.c src/util/gnunet-config.c +src/util/gnunet-crypto-tvg.c src/util/gnunet-ecc.c src/util/gnunet-qr.c src/util/gnunet-resolver.c diff --git a/src/reclaim-attribute/reclaim_attestation.c b/src/reclaim-attribute/reclaim_attestation.c index fd08b9b12..961c6ede4 100644 --- a/src/reclaim-attribute/reclaim_attestation.c +++ b/src/reclaim-attribute/reclaim_attestation.c @@ -388,7 +388,7 @@ GNUNET_RECLAIM_attestation_list_destroy ( struct GNUNET_RECLAIM_AttestationListEntry *ale; struct GNUNET_RECLAIM_AttestationListEntry *tmp_ale; - for (ale = al->list_head; NULL != ale; ale = ale->next) + for (ale = al->list_head; NULL != ale;) { if (NULL != ale->attestation) GNUNET_free (ale->attestation); diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c index 936f9cb75..0e3fae849 100644 --- a/src/reclaim-attribute/reclaim_attribute.c +++ b/src/reclaim-attribute/reclaim_attribute.c @@ -423,7 +423,7 @@ GNUNET_RECLAIM_attribute_list_destroy ( struct GNUNET_RECLAIM_AttributeListEntry *ale; struct GNUNET_RECLAIM_AttributeListEntry *tmp_ale; - for (ale = al->list_head; NULL != ale; ale = ale->next) + for (ale = al->list_head; NULL != ale;) { if (NULL != ale->attribute) GNUNET_free (ale->attribute); diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 0170ceff2..121f2b963 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c @@ -627,8 +627,10 @@ attest_iter_cb (void *cls, const struct GNUNET_RECLAIM_AttributeList *attrs) { char *attest_str; + char *attr_str; char *id; const char *attest_type; + struct GNUNET_RECLAIM_AttributeListEntry *ale; if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&attestation, &attest->id)) @@ -647,6 +649,21 @@ attest_iter_cb (void *cls, attest_type, attest->flag, id); + if (NULL != attrs) + { + fprintf (stdout, + "\t Attributes:\n"); + for (ale = attrs->list_head; NULL != ale; ale = ale->next) + { + attr_str = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type, + ale->attribute->data, + ale->attribute->data_size); + + fprintf (stdout, + "\t %s: %s\n", ale->attribute->name, attr_str); + GNUNET_free (attr_str); + } + } GNUNET_free (id); } GNUNET_RECLAIM_get_attestations_next (attest_iterator); diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 99831172b..eb8727f8f 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c @@ -1859,6 +1859,7 @@ attest_iter_finished (void *cls) env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); arm->id = htonl (ai->request_id); arm->attestation_len = htons (0); + arm->attributes_len = htons (0); GNUNET_MQ_send (ai->client->mq, env); GNUNET_CONTAINER_DLL_remove (ai->client->attest_iter_head, ai->client->attest_iter_tail, @@ -1900,10 +1901,11 @@ attest_iter_cb (void *cls, { struct Iterator *ai = cls; struct GNUNET_MQ_Envelope *env; + struct AttestationResultMessage *arm; struct GNUNET_RECLAIM_AttributeList *attrs; struct GNUNET_RECLAIM_Attestation *att; char *data_tmp; - char *attrs_size; + size_t attrs_size; if ((rd_count != 1) || (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type)) @@ -1915,8 +1917,6 @@ attest_iter_cb (void *cls, rd->data_size); attrs = GNUNET_RECLAIM_attestation_get_attributes (att); attrs_size = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); - - struct AttestationResultMessage *arm; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n", label); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1926,6 +1926,7 @@ attest_iter_cb (void *cls, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT); arm->id = htonl (ai->request_id); arm->attestation_len = htons (rd->data_size); + arm->attributes_len = htons (attrs_size); GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity); data_tmp = (char *) &arm[1]; GNUNET_memcpy (data_tmp, rd->data, rd->data_size); diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index cddee9b54..cd163e8a4 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -275,7 +275,8 @@ cleanup_handle (struct RequestHandle *handle) GNUNET_free (handle->url); if (NULL != handle->emsg) GNUNET_free (handle->emsg); - GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list); + if (NULL != handle->attr_list) + GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list); for (ego_entry = handle->ego_head; NULL != ego_entry;) { ego_tmp = ego_entry; @@ -1029,6 +1030,7 @@ attr_collect (void *cls, json_array_append (handle->resp_object, attr_obj); json_decref (attr_obj); GNUNET_free (tmp_value); + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); } diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index afab33320..5f52aa57b 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c @@ -632,7 +632,7 @@ handle_consume_ticket_result (void *cls, &ale->attestation->id)) { op->atr_cb (op->cls, &msg->identity, - le->attribute, ale->attestation); + le->attribute, ale->attestation); break; } @@ -641,11 +641,13 @@ handle_consume_ticket_result (void *cls, else // No attestations { op->atr_cb (op->cls, &msg->identity, - le->attribute, NULL); + le->attribute, NULL); } } - GNUNET_RECLAIM_attribute_list_destroy (attrs); - GNUNET_RECLAIM_attestation_list_destroy (attests); + if (NULL != attrs) + GNUNET_RECLAIM_attribute_list_destroy (attrs); + if (NULL != attests) + GNUNET_RECLAIM_attestation_list_destroy (attests); attrs = NULL; attests = NULL; } @@ -775,10 +777,13 @@ check_attestation_result (void *cls, const struct AttestationResultMessage *msg) { size_t msg_len; size_t attr_len; + size_t attest_len; msg_len = ntohs (msg->header.size); - attr_len = ntohs (msg->attestation_len); - if (msg_len != sizeof(struct AttestationResultMessage) + attr_len) + attest_len = ntohs (msg->attestation_len); + attr_len = ntohs (msg->attributes_len); + if (msg_len != sizeof(struct AttestationResultMessage) + + attr_len + attest_len) { GNUNET_break (0); return GNUNET_SYSERR; @@ -851,6 +856,7 @@ handle_attestation_result (void *cls, const struct att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len); char *read_ptr = ((char *) &msg[1]) + att_len; attrs = GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len); + if (NULL != it) { if (NULL != it->proc) @@ -862,7 +868,8 @@ handle_attestation_result (void *cls, const struct op->at_cb (op->cls, &msg->identity, att, attrs); } GNUNET_free (att); - GNUNET_RECLAIM_attribute_list_destroy (attrs); + if (NULL != attrs) + GNUNET_RECLAIM_attribute_list_destroy (attrs); return; } GNUNET_assert (0); @@ -1429,7 +1436,8 @@ GNUNET_RECLAIM_get_attestations_start ( ait->identity = *identity; GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait); env = - GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START); + GNUNET_MQ_msg (msg, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START); msg->id = htonl (rid); msg->identity = *identity; if (NULL == h->mq) @@ -1447,7 +1455,8 @@ GNUNET_RECLAIM_get_attestations_start ( * @param it the iterator */ void -GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator *ait) +GNUNET_RECLAIM_get_attestations_next (struct + GNUNET_RECLAIM_AttestationIterator *ait) { struct GNUNET_RECLAIM_Handle *h = ait->h; struct AttestationIterationNextMessage *msg; @@ -1468,7 +1477,8 @@ GNUNET_RECLAIM_get_attestations_next (struct GNUNET_RECLAIM_AttestationIterator * @param it the iterator */ void -GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator *ait) +GNUNET_RECLAIM_get_attestations_stop (struct + GNUNET_RECLAIM_AttestationIterator *ait) { struct GNUNET_RECLAIM_Handle *h = ait->h; struct GNUNET_MQ_Envelope *env; @@ -1477,7 +1487,8 @@ GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator if (NULL != h->mq) { env = - GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP); + GNUNET_MQ_msg (msg, + GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP); msg->id = htonl (ait->r_id); GNUNET_MQ_send (h->mq, env); } @@ -1485,7 +1496,6 @@ GNUNET_RECLAIM_get_attestations_stop (struct GNUNET_RECLAIM_AttestationIterator } - /** * Issues a ticket to another relying party. The identity may use * @GNUNET_RECLAIM_ticket_consume to consume the ticket -- 2.25.1