aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-11-06 22:32:17 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-11-06 22:32:17 +0900
commitbc3d776dd38651fae221a06a198d427d28693673 (patch)
tree431cc5c6bed61073ef9362937de41a74e95cc723 /src/reclaim/gnunet-service-reclaim.c
parent4db7f94ce6c8d6aed2b834c050b983de42f98718 (diff)
downloadgnunet-bc3d776dd38651fae221a06a198d427d28693673.tar.gz
gnunet-bc3d776dd38651fae221a06a198d427d28693673.zip
IPC: Convert all message payload lengths to uint16_t types.
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index e9616bef7..8b468fc8e 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -674,14 +674,14 @@ send_ticket_result (const struct IdpClient *client,
674 buf = (char*) &irm[1]; 674 buf = (char*) &irm[1];
675 if (NULL != ticket) 675 if (NULL != ticket)
676 { 676 {
677 irm->tkt_len = htonl (tkt_len); 677 irm->tkt_len = htons (tkt_len);
678 written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); 678 written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len);
679 GNUNET_assert (0 <= written); 679 GNUNET_assert (0 <= written);
680 buf += written; 680 buf += written;
681 } 681 }
682 // TODO add success member 682 // TODO add success member
683 irm->id = htonl (r_id); 683 irm->id = htonl (r_id);
684 irm->presentations_len = htonl (pres_len); 684 irm->presentations_len = htons (pres_len);
685 if (NULL != presentations) 685 if (NULL != presentations)
686 { 686 {
687 GNUNET_RECLAIM_presentation_list_serialize (presentations, 687 GNUNET_RECLAIM_presentation_list_serialize (presentations,
@@ -745,9 +745,9 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
745 size_t pkey_len; 745 size_t pkey_len;
746 746
747 size = ntohs (im->header.size); 747 size = ntohs (im->header.size);
748 attrs_len = ntohl (im->attr_len); 748 attrs_len = ntohs (im->attr_len);
749 key_len = ntohl (im->key_len); 749 key_len = ntohs (im->key_len);
750 pkey_len = ntohl (im->pkey_len); 750 pkey_len = ntohs (im->pkey_len);
751 if (size != attrs_len + key_len + pkey_len + sizeof(struct 751 if (size != attrs_len + key_len + pkey_len + sizeof(struct
752 IssueTicketMessage)) 752 IssueTicketMessage))
753 { 753 {
@@ -780,7 +780,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
780 char *buf; 780 char *buf;
781 781
782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); 782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
783 key_len = ntohl (im->key_len); 783 key_len = ntohs (im->key_len);
784 buf = (char *) &im[1]; 784 buf = (char *) &im[1];
785 if ((GNUNET_SYSERR == 785 if ((GNUNET_SYSERR ==
786 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 786 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -793,7 +793,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
793 return; 793 return;
794 } 794 }
795 buf += read; 795 buf += read;
796 pkey_len = ntohl (im->pkey_len); 796 pkey_len = ntohs (im->pkey_len);
797 if ((GNUNET_SYSERR == 797 if ((GNUNET_SYSERR ==
798 GNUNET_IDENTITY_read_public_key_from_buffer (buf, pkey_len, 798 GNUNET_IDENTITY_read_public_key_from_buffer (buf, pkey_len,
799 &rp, &read)) || 799 &rp, &read)) ||
@@ -806,7 +806,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
806 } 806 }
807 buf += read; 807 buf += read;
808 tio = GNUNET_new (struct TicketIssueOperation); 808 tio = GNUNET_new (struct TicketIssueOperation);
809 attrs_len = ntohl (im->attr_len); 809 attrs_len = ntohs (im->attr_len);
810 attrs = GNUNET_RECLAIM_attribute_list_deserialize (buf, 810 attrs = GNUNET_RECLAIM_attribute_list_deserialize (buf,
811 attrs_len); 811 attrs_len);
812 for (le = attrs->list_head; NULL != le; le = le->next) 812 for (le = attrs->list_head; NULL != le; le = le->next)
@@ -898,7 +898,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
898 char *buf; 898 char *buf;
899 899
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); 900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
901 key_len = ntohl (rm->key_len); 901 key_len = ntohs (rm->key_len);
902 buf = (char *) &rm[1]; 902 buf = (char *) &rm[1];
903 if ((GNUNET_SYSERR == 903 if ((GNUNET_SYSERR ==
904 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 904 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -911,7 +911,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
911 return; 911 return;
912 } 912 }
913 buf += read; 913 buf += read;
914 tkt_len = ntohl (rm->tkt_len); 914 tkt_len = ntohs (rm->tkt_len);
915 if ((GNUNET_SYSERR == 915 if ((GNUNET_SYSERR ==
916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, 916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
917 &ticket, &read)) || 917 &ticket, &read)) ||
@@ -972,10 +972,10 @@ consume_result_cb (void *cls,
972 attrs_len + pres_len + key_len, 972 attrs_len + pres_len + key_len,
973 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 973 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
974 crm->id = htonl (cop->r_id); 974 crm->id = htonl (cop->r_id);
975 crm->attrs_len = htonl (attrs_len); 975 crm->attrs_len = htons (attrs_len);
976 crm->presentations_len = htonl (pres_len); 976 crm->presentations_len = htons (pres_len);
977 crm->key_len = htonl (key_len); 977 crm->key_len = htons (key_len);
978 crm->result = htonl (success); 978 crm->result = htons (success);
979 data_tmp = (char *) &crm[1]; 979 data_tmp = (char *) &crm[1];
980 written = GNUNET_IDENTITY_write_public_key_to_buffer (identity, 980 written = GNUNET_IDENTITY_write_public_key_to_buffer (identity,
981 data_tmp, 981 data_tmp,
@@ -1033,7 +1033,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1033 char *buf; 1033 char *buf;
1034 1034
1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); 1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1036 key_len = ntohl (cm->key_len); 1036 key_len = ntohs (cm->key_len);
1037 buf = (char *) &cm[1]; 1037 buf = (char *) &cm[1];
1038 if ((GNUNET_SYSERR == 1038 if ((GNUNET_SYSERR ==
1039 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1039 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1046,7 +1046,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1046 return; 1046 return;
1047 } 1047 }
1048 buf += read; 1048 buf += read;
1049 tkt_len = ntohl (cm->tkt_len); 1049 tkt_len = ntohs (cm->tkt_len);
1050 if ((GNUNET_SYSERR == 1050 if ((GNUNET_SYSERR ==
1051 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, 1051 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
1052 &ticket, &read)) || 1052 &ticket, &read)) ||
@@ -1196,8 +1196,8 @@ handle_attribute_store_message (void *cls,
1196 1196
1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); 1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1198 1198
1199 data_len = ntohl (sam->attr_len); 1199 data_len = ntohs (sam->attr_len);
1200 key_len = ntohl (sam->key_len); 1200 key_len = ntohs (sam->key_len);
1201 buf = (char *) &sam[1]; 1201 buf = (char *) &sam[1];
1202 if ((GNUNET_SYSERR == 1202 if ((GNUNET_SYSERR ==
1203 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1203 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1397,8 +1397,8 @@ handle_credential_store_message (void *cls,
1397 1397
1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n"); 1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1399 1399
1400 data_len = ntohl (sam->attr_len); 1400 data_len = ntohs (sam->attr_len);
1401 key_len = ntohl (sam->key_len); 1401 key_len = ntohs (sam->key_len);
1402 buf = (char *) &sam[1]; 1402 buf = (char *) &sam[1];
1403 if ((GNUNET_SYSERR == 1403 if ((GNUNET_SYSERR ==
1404 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1404 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1868,8 +1868,8 @@ handle_attribute_delete_message (void *cls,
1868 1868
1869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); 1869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1870 1870
1871 data_len = ntohl (dam->attr_len); 1871 data_len = ntohs (dam->attr_len);
1872 key_len = ntohl (dam->key_len); 1872 key_len = ntohs (dam->key_len);
1873 buf = (char *) &dam[1]; 1873 buf = (char *) &dam[1];
1874 if ((GNUNET_SYSERR == 1874 if ((GNUNET_SYSERR ==
1875 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1875 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1975,8 +1975,8 @@ handle_credential_delete_message (void *cls,
1975 1975
1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n"); 1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1977 1977
1978 data_len = ntohl (dam->attr_len); 1978 data_len = ntohs (dam->attr_len);
1979 key_len = ntohl (dam->key_len); 1979 key_len = ntohs (dam->key_len);
1980 buf = (char *) &dam[1]; 1980 buf = (char *) &dam[1];
1981 if ((GNUNET_SYSERR == 1981 if ((GNUNET_SYSERR ==
1982 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1982 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -2032,8 +2032,8 @@ attr_iter_finished (void *cls)
2032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n"); 2032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
2033 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 2033 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
2034 arm->id = htonl (ai->request_id); 2034 arm->id = htonl (ai->request_id);
2035 arm->attr_len = htonl (0); 2035 arm->attr_len = htons (0);
2036 arm->pkey_len = htonl (0); 2036 arm->pkey_len = htons (0);
2037 GNUNET_MQ_send (ai->client->mq, env); 2037 GNUNET_MQ_send (ai->client->mq, env);
2038 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, 2038 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2039 ai->client->attr_iter_tail, 2039 ai->client->attr_iter_tail,
@@ -2097,9 +2097,9 @@ attr_iter_cb (void *cls,
2097 rd->data_size + key_len, 2097 rd->data_size + key_len,
2098 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 2098 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
2099 arm->id = htonl (ai->request_id); 2099 arm->id = htonl (ai->request_id);
2100 arm->attr_len = htonl (rd->data_size); 2100 arm->attr_len = htons (rd->data_size);
2101 data_tmp = (char *) &arm[1]; 2101 data_tmp = (char *) &arm[1];
2102 arm->pkey_len = htonl (key_len); 2102 arm->pkey_len = htons (key_len);
2103 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, 2103 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity,
2104 data_tmp, 2104 data_tmp,
2105 key_len); 2105 key_len);
@@ -2119,7 +2119,7 @@ check_iteration_start (
2119 size_t key_len; 2119 size_t key_len;
2120 2120
2121 size = ntohs (ais_msg->header.size); 2121 size = ntohs (ais_msg->header.size);
2122 key_len = ntohl (ais_msg->key_len); 2122 key_len = ntohs (ais_msg->key_len);
2123 2123
2124 if (size < key_len + sizeof(*ais_msg)) 2124 if (size < key_len + sizeof(*ais_msg))
2125 { 2125 {
@@ -2147,7 +2147,7 @@ handle_iteration_start (void *cls,
2147 2147
2148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2149 "Received ATTRIBUTE_ITERATION_START message\n"); 2149 "Received ATTRIBUTE_ITERATION_START message\n");
2150 key_len = ntohl (ais_msg->key_len); 2150 key_len = ntohs (ais_msg->key_len);
2151 if ((GNUNET_SYSERR == 2151 if ((GNUNET_SYSERR ==
2152 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], 2152 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1],
2153 key_len, 2153 key_len,
@@ -2262,8 +2262,8 @@ cred_iter_finished (void *cls)
2262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n"); 2262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CREDENTIAL_RESULT message\n");
2263 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); 2263 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
2264 arm->id = htonl (ai->request_id); 2264 arm->id = htonl (ai->request_id);
2265 arm->credential_len = htonl (0); 2265 arm->credential_len = htons (0);
2266 arm->key_len = htonl (0); 2266 arm->key_len = htons (0);
2267 GNUNET_MQ_send (ai->client->mq, env); 2267 GNUNET_MQ_send (ai->client->mq, env);
2268 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head, 2268 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2269 ai->client->cred_iter_tail, 2269 ai->client->cred_iter_tail,
@@ -2327,8 +2327,8 @@ cred_iter_cb (void *cls,
2327 rd->data_size + key_len, 2327 rd->data_size + key_len,
2328 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); 2328 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
2329 arm->id = htonl (ai->request_id); 2329 arm->id = htonl (ai->request_id);
2330 arm->credential_len = htonl (rd->data_size); 2330 arm->credential_len = htons (rd->data_size);
2331 arm->key_len = htonl (key_len); 2331 arm->key_len = htons (key_len);
2332 data_tmp = (char *) &arm[1]; 2332 data_tmp = (char *) &arm[1];
2333 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, 2333 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity,
2334 data_tmp, 2334 data_tmp,
@@ -2348,7 +2348,7 @@ check_credential_iteration_start (
2348 size_t key_len; 2348 size_t key_len;
2349 2349
2350 size = ntohs (cis_msg->header.size); 2350 size = ntohs (cis_msg->header.size);
2351 key_len = ntohl (cis_msg->key_len); 2351 key_len = ntohs (cis_msg->key_len);
2352 2352
2353 if (size < key_len + sizeof(*cis_msg)) 2353 if (size < key_len + sizeof(*cis_msg))
2354 { 2354 {
@@ -2378,7 +2378,7 @@ handle_credential_iteration_start (void *cls,
2378 2378
2379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2380 "Received CREDENTIAL_ITERATION_START message\n"); 2380 "Received CREDENTIAL_ITERATION_START message\n");
2381 key_len = ntohl (ais_msg->key_len); 2381 key_len = ntohs (ais_msg->key_len);
2382 if ((GNUNET_SYSERR == 2382 if ((GNUNET_SYSERR ==
2383 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], 2383 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1],
2384 key_len, 2384 key_len,
@@ -2516,7 +2516,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
2516 &trm[1], 2516 &trm[1],
2517 tkt_len); 2517 tkt_len);
2518 } 2518 }
2519 trm->tkt_len = htonl (tkt_len); 2519 trm->tkt_len = htons (tkt_len);
2520 trm->id = htonl (ti->r_id); 2520 trm->id = htonl (ti->r_id);
2521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); 2521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2522 GNUNET_MQ_send (ti->client->mq, env); 2522 GNUNET_MQ_send (ti->client->mq, env);
@@ -2533,7 +2533,7 @@ check_ticket_iteration_start (
2533 size_t key_len; 2533 size_t key_len;
2534 2534
2535 size = ntohs (tis_msg->header.size); 2535 size = ntohs (tis_msg->header.size);
2536 key_len = ntohl (tis_msg->key_len); 2536 key_len = ntohs (tis_msg->key_len);
2537 2537
2538 if (size < key_len + sizeof(*tis_msg)) 2538 if (size < key_len + sizeof(*tis_msg))
2539 { 2539 {
@@ -2562,7 +2562,7 @@ handle_ticket_iteration_start (
2562 2562
2563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2564 "Received TICKET_ITERATION_START message\n"); 2564 "Received TICKET_ITERATION_START message\n");
2565 key_len = ntohl (tis_msg->key_len); 2565 key_len = ntohs (tis_msg->key_len);
2566 if ((GNUNET_SYSERR == 2566 if ((GNUNET_SYSERR ==
2567 GNUNET_IDENTITY_read_private_key_from_buffer (&tis_msg[1], 2567 GNUNET_IDENTITY_read_private_key_from_buffer (&tis_msg[1],
2568 key_len, 2568 key_len,