From 8052eb6445f29eec791e7c473a15334a66c91141 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Wed, 14 Dec 2016 08:18:14 +0100 Subject: [PATCH] -fix gns mq; fix serializer --- src/credential/gnunet-credential.c | 23 ++++-------- src/credential/gnunet-service-credential.c | 41 ++-------------------- src/credential/plugin_rest_credential.c | 16 +++------ src/gns/gns_api.c | 12 ++++--- 4 files changed, 21 insertions(+), 71 deletions(-) diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index 82f0e349c..a728939dc 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c @@ -170,27 +170,18 @@ handle_verify_result (void *cls, { for (i=0;idelegation_chain_entry->issuer_key; dd[i].subject_key = dq_entry->delegation_chain_entry->subject_key; dd[i].issuer_attribute = dq_entry->delegation_chain_entry->issuer_attribute; - dd[i].issuer_attribute_len = strlen (dq_entry->delegation_chain_entry->issuer_attribute); + dd[i].issuer_attribute_len = strlen (dq_entry->delegation_chain_entry->issuer_attribute)+1; dd[i].subject_attribute_len = 0; if (NULL != dq_entry->delegation_chain_entry->subject_attribute) { dd[i].subject_attribute = dq_entry->delegation_chain_entry->subject_attribute; - dd[i].subject_attribute_len = strlen(dq_entry->delegation_chain_entry->subject_attribute); + dd[i].subject_attribute_len = strlen(dq_entry->delegation_chain_entry->subject_attribute)+1; } dq_entry = dq_entry->parent; } @@ -471,7 +471,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh) * Get serialized record data * Append at the end of rmsg */ - cred.issuer_key = vrh->credential->issuer_key; + cred.issuer_key = vrh->credential->issuer_key; cred.subject_key = vrh->credential->issuer_key; cred.issuer_attribute_len = strlen((char*)&vrh->credential[1]); cred.issuer_attribute = (char*)&vrh->credential[1]; @@ -496,41 +496,6 @@ send_lookup_response (struct VerifyRequestHandle *vrh) size, (char*)&rmsg[1])); - - /*for (dq_entry = vrh->chain_end; NULL != dq_entry; dq_entry = dq_entry->parent) - { - if (NULL == dq_entry->delegation_chain_entry) - break; - size += sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry); - if (NULL != dq_entry->delegation_chain_entry->subject_attribute) - size += strlen (dq_entry->delegation_chain_entry->subject_attribute) + 1; - size += strlen(dq_entry->delegation_chain_entry->issuer_attribute) + 1; - d_count++; - }*/ - - //TODO refactor into serializer module - /*write_ptr = (char*)&rmsg[1] + vrh->credential_size; - for (dq_entry = vrh->chain_end; NULL != dq_entry; dq_entry = dq_entry->parent) - { - if (NULL == dq_entry->delegation_chain_entry) - break; - memcpy (write_ptr, - dq_entry->delegation_chain_entry, - sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry)); - write_ptr += sizeof (struct GNUNET_CREDENTIAL_DelegationChainEntry); - if (NULL != dq_entry->delegation_chain_entry->subject_attribute) - { - GNUNET_snprintf (write_ptr, - strlen (dq_entry->delegation_chain_entry->subject_attribute) + 2, - "%s;", - dq_entry->delegation_chain_entry->subject_attribute); - write_ptr += strlen (dq_entry->delegation_chain_entry->subject_attribute) + 1; - } - memcpy (write_ptr, - dq_entry->delegation_chain_entry->issuer_attribute, - strlen(dq_entry->delegation_chain_entry->issuer_attribute)); - write_ptr += strlen(dq_entry->delegation_chain_entry->issuer_attribute) + 1; - }*/ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(vrh->client), env); GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh); diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c index 798f76049..cdd0e86e9 100644 --- a/src/credential/plugin_rest_credential.c +++ b/src/credential/plugin_rest_credential.c @@ -190,8 +190,6 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch { char *subject; char *issuer; - char iss_attribute[delegation_chain_entry->issuer_attribute_len]; - char sub_attribute[delegation_chain_entry->subject_attribute_len]; json_t *attr_obj; issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->issuer_key); @@ -208,22 +206,16 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch return NULL; } attr_obj = json_object (); - memcpy (iss_attribute, - delegation_chain_entry->issuer_attribute, - delegation_chain_entry->issuer_attribute_len); - iss_attribute[delegation_chain_entry->issuer_attribute_len] = '\0'; json_object_set_new (attr_obj, "subject", json_string (subject)); json_object_set_new (attr_obj, "issuer", json_string (issuer)); - json_object_set_new (attr_obj, "issuer_attribute", json_string (iss_attribute)); + json_object_set_new (attr_obj, "issuer_attribute", + json_string (delegation_chain_entry->issuer_attribute)); if (0 < delegation_chain_entry->subject_attribute_len) { - memcpy (sub_attribute, - delegation_chain_entry->subject_attribute, - delegation_chain_entry->subject_attribute_len); - sub_attribute[delegation_chain_entry->subject_attribute_len] = '\0'; - json_object_set_new (attr_obj, "subject_attribute", json_string (sub_attribute)); + json_object_set_new (attr_obj, "subject_attribute", + json_string (delegation_chain_entry->subject_attribute)); } GNUNET_free (subject); return attr_obj; diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index acb56f2c4..5ad7b4fae 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c @@ -354,11 +354,7 @@ handle_result (void *cls, return; proc = lr->lookup_proc; proc_cls = lr->proc_cls; - GNUNET_CONTAINER_DLL_remove (handle->lookup_head, - handle->lookup_tail, - lr); - GNUNET_free (lr->env); - GNUNET_free (lr); + GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_records_deserialize (mlen, (const char*) &lookup_msg[1], @@ -367,6 +363,12 @@ handle_result (void *cls, proc (proc_cls, rd_count, rd); + GNUNET_CONTAINER_DLL_remove (handle->lookup_head, + handle->lookup_tail, + lr); + if (NULL != lr->env) + GNUNET_MQ_discard (lr->env); + GNUNET_free (lr); } -- 2.25.1