From 3e958fd99a5adeec8245005e44c349dd5be1b082 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Mon, 5 Dec 2016 19:57:16 +0100 Subject: [PATCH] -add simple test --- src/credential/credential_api.c | 9 ++++++--- src/credential/gnunet-credential.c | 11 +++++++++-- src/credential/plugin_gnsrecord_credential.c | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index 88f5f4e17..344bb6e63 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c @@ -369,7 +369,7 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, struct GNUNET_CREDENTIAL_Request *vr; size_t nlen; - if (NULL == issuer_attribute) + if (NULL == issuer_attribute || NULL == subject_attribute) { GNUNET_break (0); return NULL; @@ -378,7 +378,7 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to verify `%s' in CREDENTIAL\n", issuer_attribute); - nlen = strlen (issuer_attribute) + 1; + nlen = strlen (issuer_attribute) + 1 + strlen (subject_attribute) + 1; if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr)) { GNUNET_break (0); @@ -396,8 +396,11 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle, v_msg->subject_key = *subject_key; v_msg->issuer_key = *issuer_key; GNUNET_memcpy (&v_msg[1], + issuer_attribute, + strlen (issuer_attribute)); + GNUNET_memcpy (((char*)&v_msg[1]) + strlen (issuer_attribute) + 1, subject_attribute, - nlen); + strlen (subject_attribute)); GNUNET_CONTAINER_DLL_insert (handle->verify_head, handle->verify_tail, vr); diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index 874aa29cb..a7b92447b 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c @@ -280,7 +280,14 @@ run (void *cls, { fprintf (stderr, _("Failed to connect to CREDENTIAL\n")); - return; + GNUNET_SCHEDULER_shutdown (); + } + + if (NULL == issuer_attr || NULL == subject_credential) + { + fprintf (stderr, + _("You must provide issuer and subject attributes\n")); + GNUNET_SCHEDULER_shutdown (); } @@ -334,7 +341,7 @@ main (int argc, char *const *argv) {'s', "subject", "PKEY", gettext_noop ("The public key of the subject to lookup the credential for"), 1, &GNUNET_GETOPT_set_string, &subject_key}, - {'c', "credential", "CRED", + {'b', "credential", "CRED", gettext_noop ("The name of the credential presented by the subject"), 1, &GNUNET_GETOPT_set_string, &subject_credential}, {'i', "issuer", "PKEY", diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index 67fd32e49..721e19fdb 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c @@ -136,7 +136,7 @@ credential_string_to_value (void *cls, char issuer_pkey[enclen + 1]; char name[253 + 1]; - if (5 != SSCANF (s, + if (3 != SSCANF (s, "%52s %52s %253s", subject_pkey, issuer_pkey, -- 2.25.1