diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-13 19:55:46 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-13 19:55:46 +0200 |
commit | fa2978883e1585b1eeff3a22b7a9b4f174a45ca3 (patch) | |
tree | 52800dd5062534729be80227608def6f6c0c45ac /src/credential/gnunet-service-credential.c | |
parent | 2bb2faa207e4015609100a1aca38af344c65596f (diff) | |
download | gnunet-fa2978883e1585b1eeff3a22b7a9b4f174a45ca3.tar.gz gnunet-fa2978883e1585b1eeff3a22b7a9b4f174a45ca3.zip |
get rid of plain memcpy calls
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r-- | src/credential/gnunet-service-credential.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index 399371a2e..29bdf63d8 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -61,17 +61,17 @@ struct DelegationChainEntry | |||
61 | * The issuer | 61 | * The issuer |
62 | */ | 62 | */ |
63 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; | 63 | struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * The subject | 66 | * The subject |
67 | */ | 67 | */ |
68 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; | 68 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_key; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * The issued attribute | 71 | * The issued attribute |
72 | */ | 72 | */ |
73 | char *issuer_attribute; | 73 | char *issuer_attribute; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * The delegated attribute | 76 | * The delegated attribute |
77 | */ | 77 | */ |
@@ -92,7 +92,7 @@ struct CredentialRecordEntry | |||
92 | * DLL | 92 | * DLL |
93 | */ | 93 | */ |
94 | struct CredentialRecordEntry *prev; | 94 | struct CredentialRecordEntry *prev; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * Number of references in delegation chains | 97 | * Number of references in delegation chains |
98 | */ | 98 | */ |
@@ -409,7 +409,7 @@ cleanup_handle (struct VerifyRequestHandle *vrh) | |||
409 | } | 409 | } |
410 | cleanup_delegation_set (vrh->root_set); | 410 | cleanup_delegation_set (vrh->root_set); |
411 | GNUNET_free_non_null (vrh->issuer_attribute); | 411 | GNUNET_free_non_null (vrh->issuer_attribute); |
412 | for (cr_entry = vrh->cred_chain_head; | 412 | for (cr_entry = vrh->cred_chain_head; |
413 | NULL != vrh->cred_chain_head; | 413 | NULL != vrh->cred_chain_head; |
414 | cr_entry = vrh->cred_chain_head) | 414 | cr_entry = vrh->cred_chain_head) |
415 | { | 415 | { |
@@ -543,7 +543,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
543 | else | 543 | else |
544 | rmsg->cred_found = htonl (GNUNET_NO); | 544 | rmsg->cred_found = htonl (GNUNET_NO); |
545 | 545 | ||
546 | GNUNET_assert (-1 != | 546 | GNUNET_assert (-1 != |
547 | GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, | 547 | GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size, |
548 | dd, | 548 | dd, |
549 | vrh->cred_chain_size, | 549 | vrh->cred_chain_size, |
@@ -587,7 +587,7 @@ backward_resolution (void* cls, | |||
587 | "Got %d attrs\n", rd_count); | 587 | "Got %d attrs\n", rd_count); |
588 | 588 | ||
589 | // Each OR | 589 | // Each OR |
590 | for (uint32_t i=0; i < rd_count; i++) | 590 | for (uint32_t i=0; i < rd_count; i++) |
591 | { | 591 | { |
592 | if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type) | 592 | if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type) |
593 | continue; | 593 | continue; |
@@ -665,10 +665,10 @@ backward_resolution (void* cls, | |||
665 | /** | 665 | /** |
666 | * Check if this delegation already matches one of our credentials | 666 | * Check if this delegation already matches one of our credentials |
667 | */ | 667 | */ |
668 | for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL; | 668 | for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL; |
669 | cred_pointer = cred_pointer->next) | 669 | cred_pointer = cred_pointer->next) |
670 | { | 670 | { |
671 | if(0 != memcmp (&set->subject_key, | 671 | if(0 != memcmp (&set->subject_key, |
672 | &cred_pointer->credential->issuer_key, | 672 | &cred_pointer->credential->issuer_key, |
673 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | 673 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) |
674 | continue; | 674 | continue; |
@@ -769,7 +769,7 @@ backward_resolution (void* cls, | |||
769 | return; | 769 | return; |
770 | 770 | ||
771 | } | 771 | } |
772 | } | 772 | } |
773 | 773 | ||
774 | 774 | ||
775 | /** | 775 | /** |
@@ -809,7 +809,7 @@ delegation_chain_resolution_start (void* cls) | |||
809 | } | 809 | } |
810 | 810 | ||
811 | /** | 811 | /** |
812 | * Check for attributes from the issuer and follow the chain | 812 | * Check for attributes from the issuer and follow the chain |
813 | * till you get the required subject's attributes | 813 | * till you get the required subject's attributes |
814 | */ | 814 | */ |
815 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + strlen (".gnu") + 1]; | 815 | char issuer_attribute_name[strlen (vrh->issuer_attribute) + strlen (".gnu") + 1]; |
@@ -821,9 +821,9 @@ delegation_chain_resolution_start (void* cls) | |||
821 | "Looking up %s\n", issuer_attribute_name); | 821 | "Looking up %s\n", issuer_attribute_name); |
822 | ds_entry = GNUNET_new (struct DelegationSetQueueEntry); | 822 | ds_entry = GNUNET_new (struct DelegationSetQueueEntry); |
823 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 823 | ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
824 | memcpy (ds_entry->issuer_key, | 824 | GNUNET_memcpy (ds_entry->issuer_key, |
825 | &vrh->issuer_key, | 825 | &vrh->issuer_key, |
826 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 826 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
827 | ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute); | 827 | ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute); |
828 | ds_entry->handle = vrh; | 828 | ds_entry->handle = vrh; |
829 | ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); | 829 | ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute); |
@@ -869,7 +869,7 @@ check_verify (void *cls, | |||
869 | 869 | ||
870 | static void | 870 | static void |
871 | handle_verify (void *cls, | 871 | handle_verify (void *cls, |
872 | const struct VerifyMessage *v_msg) | 872 | const struct VerifyMessage *v_msg) |
873 | { | 873 | { |
874 | struct VerifyRequestHandle *vrh; | 874 | struct VerifyRequestHandle *vrh; |
875 | struct GNUNET_SERVICE_Client *client = cls; | 875 | struct GNUNET_SERVICE_Client *client = cls; |
@@ -886,7 +886,9 @@ handle_verify (void *cls, | |||
886 | "Received VERIFY message\n"); | 886 | "Received VERIFY message\n"); |
887 | utf_in = (const char *) &v_msg[1]; | 887 | utf_in = (const char *) &v_msg[1]; |
888 | GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); | 888 | GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); |
889 | GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len)); | 889 | GNUNET_memcpy (issuer_attribute, |
890 | attr, | ||
891 | ntohs (v_msg->issuer_attribute_len)); | ||
890 | issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0'; | 892 | issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0'; |
891 | vrh = GNUNET_new (struct VerifyRequestHandle); | 893 | vrh = GNUNET_new (struct VerifyRequestHandle); |
892 | GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); | 894 | GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); |
@@ -897,7 +899,7 @@ handle_verify (void *cls, | |||
897 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); | 899 | vrh->issuer_attribute = GNUNET_strdup (issuer_attribute); |
898 | if (0 == strlen (issuer_attribute)) | 900 | if (0 == strlen (issuer_attribute)) |
899 | { | 901 | { |
900 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 902 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
901 | "No issuer attribute provided!\n"); | 903 | "No issuer attribute provided!\n"); |
902 | send_lookup_response (vrh); | 904 | send_lookup_response (vrh); |
903 | return; | 905 | return; |
@@ -907,7 +909,7 @@ handle_verify (void *cls, | |||
907 | * TODO: cleanup! | 909 | * TODO: cleanup! |
908 | */ | 910 | */ |
909 | credentials_count = ntohl(v_msg->c_count); | 911 | credentials_count = ntohl(v_msg->c_count); |
910 | credential_data_size = ntohs (v_msg->header.size) | 912 | credential_data_size = ntohs (v_msg->header.size) |
911 | - sizeof (struct VerifyMessage) | 913 | - sizeof (struct VerifyMessage) |
912 | - ntohs (v_msg->issuer_attribute_len) | 914 | - ntohs (v_msg->issuer_attribute_len) |
913 | - 1; | 915 | - 1; |
@@ -918,7 +920,7 @@ handle_verify (void *cls, | |||
918 | credentials_count, | 920 | credentials_count, |
919 | credentials)) | 921 | credentials)) |
920 | { | 922 | { |
921 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 923 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
922 | "Cannot deserialize credentials!\n"); | 924 | "Cannot deserialize credentials!\n"); |
923 | send_lookup_response (vrh); | 925 | send_lookup_response (vrh); |
924 | return; | 926 | return; |
@@ -1015,7 +1017,7 @@ handle_cred_collection_finished_cb (void *cls) | |||
1015 | 1017 | ||
1016 | static void | 1018 | static void |
1017 | handle_collect (void *cls, | 1019 | handle_collect (void *cls, |
1018 | const struct CollectMessage *c_msg) | 1020 | const struct CollectMessage *c_msg) |
1019 | { | 1021 | { |
1020 | char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; | 1022 | char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; |
1021 | char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; | 1023 | char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1]; |
@@ -1030,7 +1032,9 @@ handle_collect (void *cls, | |||
1030 | utf_in = (const char *) &c_msg[1]; | 1032 | utf_in = (const char *) &c_msg[1]; |
1031 | GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); | 1033 | GNUNET_STRINGS_utf8_tolower (utf_in, attrptr); |
1032 | 1034 | ||
1033 | GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len)); | 1035 | GNUNET_memcpy (issuer_attribute, |
1036 | attr, | ||
1037 | ntohs (c_msg->issuer_attribute_len)); | ||
1034 | issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0'; | 1038 | issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0'; |
1035 | vrh = GNUNET_new (struct VerifyRequestHandle); | 1039 | vrh = GNUNET_new (struct VerifyRequestHandle); |
1036 | GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); | 1040 | GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh); |
@@ -1043,7 +1047,7 @@ handle_collect (void *cls, | |||
1043 | 1047 | ||
1044 | if (0 == strlen (issuer_attribute)) | 1048 | if (0 == strlen (issuer_attribute)) |
1045 | { | 1049 | { |
1046 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1050 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1047 | "No issuer attribute provided!\n"); | 1051 | "No issuer attribute provided!\n"); |
1048 | send_lookup_response (vrh); | 1052 | send_lookup_response (vrh); |
1049 | return; | 1053 | return; |