aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 19:57:16 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 19:57:16 +0100
commit3e958fd99a5adeec8245005e44c349dd5be1b082 (patch)
tree17635ca2e0099b8440e584cd23370074da810f05 /src
parentfcb5ecaede036d2bb89e5123345fd391520c344a (diff)
downloadgnunet-3e958fd99a5adeec8245005e44c349dd5be1b082.tar.gz
gnunet-3e958fd99a5adeec8245005e44c349dd5be1b082.zip
-add simple test
Diffstat (limited to 'src')
-rw-r--r--src/credential/credential_api.c9
-rw-r--r--src/credential/gnunet-credential.c11
-rw-r--r--src/credential/plugin_gnsrecord_credential.c2
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,
369 struct GNUNET_CREDENTIAL_Request *vr; 369 struct GNUNET_CREDENTIAL_Request *vr;
370 size_t nlen; 370 size_t nlen;
371 371
372 if (NULL == issuer_attribute) 372 if (NULL == issuer_attribute || NULL == subject_attribute)
373 { 373 {
374 GNUNET_break (0); 374 GNUNET_break (0);
375 return NULL; 375 return NULL;
@@ -378,7 +378,7 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
378 LOG (GNUNET_ERROR_TYPE_DEBUG, 378 LOG (GNUNET_ERROR_TYPE_DEBUG,
379 "Trying to verify `%s' in CREDENTIAL\n", 379 "Trying to verify `%s' in CREDENTIAL\n",
380 issuer_attribute); 380 issuer_attribute);
381 nlen = strlen (issuer_attribute) + 1; 381 nlen = strlen (issuer_attribute) + 1 + strlen (subject_attribute) + 1;
382 if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr)) 382 if (nlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*vr))
383 { 383 {
384 GNUNET_break (0); 384 GNUNET_break (0);
@@ -396,8 +396,11 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
396 v_msg->subject_key = *subject_key; 396 v_msg->subject_key = *subject_key;
397 v_msg->issuer_key = *issuer_key; 397 v_msg->issuer_key = *issuer_key;
398 GNUNET_memcpy (&v_msg[1], 398 GNUNET_memcpy (&v_msg[1],
399 issuer_attribute,
400 strlen (issuer_attribute));
401 GNUNET_memcpy (((char*)&v_msg[1]) + strlen (issuer_attribute) + 1,
399 subject_attribute, 402 subject_attribute,
400 nlen); 403 strlen (subject_attribute));
401 GNUNET_CONTAINER_DLL_insert (handle->verify_head, 404 GNUNET_CONTAINER_DLL_insert (handle->verify_head,
402 handle->verify_tail, 405 handle->verify_tail,
403 vr); 406 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,
280 { 280 {
281 fprintf (stderr, 281 fprintf (stderr,
282 _("Failed to connect to CREDENTIAL\n")); 282 _("Failed to connect to CREDENTIAL\n"));
283 return; 283 GNUNET_SCHEDULER_shutdown ();
284 }
285
286 if (NULL == issuer_attr || NULL == subject_credential)
287 {
288 fprintf (stderr,
289 _("You must provide issuer and subject attributes\n"));
290 GNUNET_SCHEDULER_shutdown ();
284 } 291 }
285 292
286 293
@@ -334,7 +341,7 @@ main (int argc, char *const *argv)
334 {'s', "subject", "PKEY", 341 {'s', "subject", "PKEY",
335 gettext_noop ("The public key of the subject to lookup the credential for"), 1, 342 gettext_noop ("The public key of the subject to lookup the credential for"), 1,
336 &GNUNET_GETOPT_set_string, &subject_key}, 343 &GNUNET_GETOPT_set_string, &subject_key},
337 {'c', "credential", "CRED", 344 {'b', "credential", "CRED",
338 gettext_noop ("The name of the credential presented by the subject"), 1, 345 gettext_noop ("The name of the credential presented by the subject"), 1,
339 &GNUNET_GETOPT_set_string, &subject_credential}, 346 &GNUNET_GETOPT_set_string, &subject_credential},
340 {'i', "issuer", "PKEY", 347 {'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,
136 char issuer_pkey[enclen + 1]; 136 char issuer_pkey[enclen + 1];
137 char name[253 + 1]; 137 char name[253 + 1];
138 138
139 if (5 != SSCANF (s, 139 if (3 != SSCANF (s,
140 "%52s %52s %253s", 140 "%52s %52s %253s",
141 subject_pkey, 141 subject_pkey,
142 issuer_pkey, 142 issuer_pkey,