diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 11:45:51 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 11:45:51 +0100 |
commit | 83beeae39bf48f3957c80bf0fd03c221bce15bc1 (patch) | |
tree | 5bb62a686532a9299011761c6d9ba9348d52399a | |
parent | b23c010728c1c808796a7948aa7ff9f9a08966ac (diff) | |
download | gnunet-83beeae39bf48f3957c80bf0fd03c221bce15bc1.tar.gz gnunet-83beeae39bf48f3957c80bf0fd03c221bce15bc1.zip |
-fix some coverity issues wrt reclaim
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 5 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 15 | ||||
-rw-r--r-- | src/reclaim/oidc_helper.c | 14 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_openid_connect.c | 50 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 131 | ||||
-rw-r--r-- | src/reclaim/reclaim_api.c | 20 |
6 files changed, 141 insertions, 94 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 913b667b7..04c12735b 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -731,9 +731,12 @@ static int | |||
731 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | 731 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) |
732 | { | 732 | { |
733 | uint16_t size; | 733 | uint16_t size; |
734 | size_t attrs_len; | ||
734 | 735 | ||
735 | size = ntohs (im->header.size); | 736 | size = ntohs (im->header.size); |
736 | if (size <= sizeof(struct IssueTicketMessage)) | 737 | attrs_len = ntohs (im->attr_len); |
738 | |||
739 | if (attrs_len > size - sizeof(struct IssueTicketMessage)) | ||
737 | { | 740 | { |
738 | GNUNET_break (0); | 741 | GNUNET_break (0); |
739 | return GNUNET_SYSERR; | 742 | return GNUNET_SYSERR; |
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index ef2303bd7..48b3fe214 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -690,7 +690,10 @@ rvk_move_attr_cb (void *cls, | |||
690 | return; | 690 | return; |
691 | } | 691 | } |
692 | GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id); | 692 | GNUNET_RECLAIM_id_generate (&rvk->move_attr->new_id); |
693 | new_label = NULL; | 693 | new_label = |
694 | GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | ||
695 | sizeof (rvk->move_attr->new_id)); | ||
696 | |||
694 | attr_data = NULL; | 697 | attr_data = NULL; |
695 | // new_rd = *rd; | 698 | // new_rd = *rd; |
696 | for (int i = 0; i < rd_count; i++) | 699 | for (int i = 0; i < rd_count; i++) |
@@ -714,9 +717,6 @@ rvk_move_attr_cb (void *cls, | |||
714 | new_rd[i].record_type = rd[i].record_type; | 717 | new_rd[i].record_type = rd[i].record_type; |
715 | new_rd[i].flags = rd[i].flags; | 718 | new_rd[i].flags = rd[i].flags; |
716 | new_rd[i].expiration_time = rd[i].expiration_time; | 719 | new_rd[i].expiration_time = rd[i].expiration_time; |
717 | new_label = | ||
718 | GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | ||
719 | sizeof (rvk->move_attr->new_id)); | ||
720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); | 720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); |
721 | GNUNET_free (claim); | 721 | GNUNET_free (claim); |
722 | } | 722 | } |
@@ -738,9 +738,6 @@ rvk_move_attr_cb (void *cls, | |||
738 | new_rd[i].record_type = rd[i].record_type; | 738 | new_rd[i].record_type = rd[i].record_type; |
739 | new_rd[i].flags = rd[i].flags; | 739 | new_rd[i].flags = rd[i].flags; |
740 | new_rd[i].expiration_time = rd[i].expiration_time; | 740 | new_rd[i].expiration_time = rd[i].expiration_time; |
741 | new_label = | ||
742 | GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | ||
743 | sizeof (rvk->move_attr->new_id)); | ||
744 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", | 741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential %s\n", |
745 | new_label); | 742 | new_label); |
746 | GNUNET_free (credential); | 743 | GNUNET_free (credential); |
@@ -1400,7 +1397,7 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
1400 | attrs_record, | 1397 | attrs_record, |
1401 | &store_ticket_issue_cont, | 1398 | &store_ticket_issue_cont, |
1402 | ih); | 1399 | ih); |
1403 | for (j = 0; j > i; j++) | 1400 | for (j = 0; j < i; j++) |
1404 | { | 1401 | { |
1405 | if (attrs_record[j].record_type | 1402 | if (attrs_record[j].record_type |
1406 | != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION) | 1403 | != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION) |
@@ -1585,7 +1582,7 @@ filter_tickets_cb (void *cls, | |||
1585 | cleanup_issue_handle (tih); | 1582 | cleanup_issue_handle (tih); |
1586 | return; | 1583 | return; |
1587 | } | 1584 | } |
1588 | 1585 | GNUNET_RECLAIM_presentation_list_destroy (ticket_presentations); | |
1589 | // ticket not found in current record, checking next record set | 1586 | // ticket not found in current record, checking next record set |
1590 | GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1); | 1587 | GNUNET_NAMESTORE_zone_iterator_next (tih->ns_it, 1); |
1591 | } | 1588 | } |
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index bd3a8ee05..7b24ee598 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c | |||
@@ -839,11 +839,17 @@ int | |||
839 | OIDC_access_token_parse (const char *token, | 839 | OIDC_access_token_parse (const char *token, |
840 | struct GNUNET_RECLAIM_Ticket **ticket) | 840 | struct GNUNET_RECLAIM_Ticket **ticket) |
841 | { | 841 | { |
842 | if (sizeof (struct GNUNET_RECLAIM_Ticket) != | 842 | size_t sret; |
843 | GNUNET_STRINGS_base64_decode (token, | 843 | char *decoded; |
844 | strlen (token), | 844 | sret = GNUNET_STRINGS_base64_decode (token, |
845 | (void**) ticket)) | 845 | strlen (token), |
846 | (void**) &decoded); | ||
847 | if (sizeof (struct GNUNET_RECLAIM_Ticket) != sret) | ||
848 | { | ||
849 | GNUNET_free (decoded); | ||
846 | return GNUNET_SYSERR; | 850 | return GNUNET_SYSERR; |
851 | } | ||
852 | *ticket = (struct GNUNET_RECLAIM_Ticket *) decoded; | ||
847 | return GNUNET_OK; | 853 | return GNUNET_OK; |
848 | } | 854 | } |
849 | 855 | ||
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index 0ee61755b..c6259d745 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -686,7 +686,10 @@ do_userinfo_error (void *cls) | |||
686 | handle->emsg, | 686 | handle->emsg, |
687 | (NULL != handle->edesc) ? handle->edesc : ""); | 687 | (NULL != handle->edesc) ? handle->edesc : ""); |
688 | resp = GNUNET_REST_create_response (""); | 688 | resp = GNUNET_REST_create_response (""); |
689 | MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); | 689 | GNUNET_assert (MHD_NO != |
690 | MHD_add_response_header (resp, | ||
691 | MHD_HTTP_HEADER_WWW_AUTHENTICATE, | ||
692 | "Bearer")); | ||
690 | handle->proc (handle->proc_cls, resp, handle->response_code); | 693 | handle->proc (handle->proc_cls, resp, handle->response_code); |
691 | cleanup_handle (handle); | 694 | cleanup_handle (handle); |
692 | GNUNET_free (error); | 695 | GNUNET_free (error); |
@@ -713,7 +716,8 @@ do_redirect_error (void *cls) | |||
713 | (NULL != handle->oidc->state) ? "&state=" : "", | 716 | (NULL != handle->oidc->state) ? "&state=" : "", |
714 | (NULL != handle->oidc->state) ? handle->oidc->state : ""); | 717 | (NULL != handle->oidc->state) ? handle->oidc->state : ""); |
715 | resp = GNUNET_REST_create_response (""); | 718 | resp = GNUNET_REST_create_response (""); |
716 | MHD_add_response_header (resp, "Location", redirect); | 719 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
720 | "Location", redirect)); | ||
717 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 721 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
718 | cleanup_handle (handle); | 722 | cleanup_handle (handle); |
719 | GNUNET_free (redirect); | 723 | GNUNET_free (redirect); |
@@ -1022,7 +1026,8 @@ oidc_ticket_issue_cb (void *cls, | |||
1022 | handle->oidc->state); | 1026 | handle->oidc->state); |
1023 | } | 1027 | } |
1024 | resp = GNUNET_REST_create_response (""); | 1028 | resp = GNUNET_REST_create_response (""); |
1025 | MHD_add_response_header (resp, "Location", redirect_uri); | 1029 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
1030 | "Location", redirect_uri)); | ||
1026 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 1031 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
1027 | cleanup_handle (handle); | 1032 | cleanup_handle (handle); |
1028 | GNUNET_free (redirect_uri); | 1033 | GNUNET_free (redirect_uri); |
@@ -1381,7 +1386,8 @@ build_redirect (void *cls) | |||
1381 | handle->oidc->state); | 1386 | handle->oidc->state); |
1382 | } | 1387 | } |
1383 | resp = GNUNET_REST_create_response (""); | 1388 | resp = GNUNET_REST_create_response (""); |
1384 | MHD_add_response_header (resp, "Location", redirect_uri); | 1389 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
1390 | "Location", redirect_uri)); | ||
1385 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 1391 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
1386 | cleanup_handle (handle); | 1392 | cleanup_handle (handle); |
1387 | GNUNET_free (redirect_uri); | 1393 | GNUNET_free (redirect_uri); |
@@ -1764,8 +1770,12 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1764 | "%s;Max-Age=%d", | 1770 | "%s;Max-Age=%d", |
1765 | cookie, | 1771 | cookie, |
1766 | OIDC_COOKIE_EXPIRATION); | 1772 | OIDC_COOKIE_EXPIRATION); |
1767 | MHD_add_response_header (resp, "Set-Cookie", header_val); | 1773 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
1768 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", "POST"); | 1774 | "Set-Cookie", header_val)); |
1775 | GNUNET_assert (MHD_NO != | ||
1776 | MHD_add_response_header (resp, | ||
1777 | "Access-Control-Allow-Methods", | ||
1778 | "POST")); | ||
1769 | GNUNET_CRYPTO_hash (cookie, strlen (cookie), &cache_key); | 1779 | GNUNET_CRYPTO_hash (cookie, strlen (cookie), &cache_key); |
1770 | 1780 | ||
1771 | if (0 != strcmp (json_string_value (identity), "Denied")) | 1781 | if (0 != strcmp (json_string_value (identity), "Denied")) |
@@ -1880,7 +1890,8 @@ parse_credentials_post_body (struct RequestHandle *handle, | |||
1880 | } | 1890 | } |
1881 | pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, | 1891 | pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
1882 | &cache_key); | 1892 | &cache_key); |
1883 | if (NULL == pass) { | 1893 | if (NULL == pass) |
1894 | { | ||
1884 | GNUNET_free (*client_id); | 1895 | GNUNET_free (*client_id); |
1885 | *client_id = NULL; | 1896 | *client_id = NULL; |
1886 | return GNUNET_SYSERR; | 1897 | return GNUNET_SYSERR; |
@@ -2134,6 +2145,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2134 | GNUNET_free (code); | 2145 | GNUNET_free (code); |
2135 | if (NULL != nonce) | 2146 | if (NULL != nonce) |
2136 | GNUNET_free (nonce); | 2147 | GNUNET_free (nonce); |
2148 | GNUNET_RECLAIM_attribute_list_destroy (cl); | ||
2149 | GNUNET_RECLAIM_presentation_list_destroy (pl); | ||
2137 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2150 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
2138 | return; | 2151 | return; |
2139 | } | 2152 | } |
@@ -2149,6 +2162,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2149 | handle->edesc = GNUNET_strdup ("No signing secret configured!"); | 2162 | handle->edesc = GNUNET_strdup ("No signing secret configured!"); |
2150 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 2163 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
2151 | GNUNET_free (code); | 2164 | GNUNET_free (code); |
2165 | GNUNET_RECLAIM_attribute_list_destroy (cl); | ||
2166 | GNUNET_RECLAIM_presentation_list_destroy (pl); | ||
2152 | if (NULL != nonce) | 2167 | if (NULL != nonce) |
2153 | GNUNET_free (nonce); | 2168 | GNUNET_free (nonce); |
2154 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 2169 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
@@ -2191,9 +2206,14 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2191 | &json_response); | 2206 | &json_response); |
2192 | 2207 | ||
2193 | resp = GNUNET_REST_create_response (json_response); | 2208 | resp = GNUNET_REST_create_response (json_response); |
2194 | MHD_add_response_header (resp, "Cache-Control", "no-store"); | 2209 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
2195 | MHD_add_response_header (resp, "Pragma", "no-cache"); | 2210 | "Cache-Control", |
2196 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 2211 | "no-store")); |
2212 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, | ||
2213 | "Pragma", "no-cache")); | ||
2214 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, | ||
2215 | "Content-Type", | ||
2216 | "application/json")); | ||
2197 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 2217 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
2198 | GNUNET_RECLAIM_attribute_list_destroy (cl); | 2218 | GNUNET_RECLAIM_attribute_list_destroy (cl); |
2199 | GNUNET_RECLAIM_presentation_list_destroy (pl); | 2219 | GNUNET_RECLAIM_presentation_list_destroy (pl); |
@@ -2665,8 +2685,14 @@ oidc_config_cors (struct GNUNET_REST_RequestHandle *con_handle, | |||
2665 | 2685 | ||
2666 | // For now, independent of path return all options | 2686 | // For now, independent of path return all options |
2667 | resp = GNUNET_REST_create_response (NULL); | 2687 | resp = GNUNET_REST_create_response (NULL); |
2668 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | 2688 | GNUNET_assert (MHD_NO != |
2669 | MHD_add_response_header (resp, "Access-Control-Allow-Origin", "*"); | 2689 | MHD_add_response_header (resp, |
2690 | "Access-Control-Allow-Methods", | ||
2691 | allow_methods)); | ||
2692 | GNUNET_assert (MHD_NO != | ||
2693 | MHD_add_response_header (resp, | ||
2694 | "Access-Control-Allow-Origin", | ||
2695 | "*")); | ||
2670 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 2696 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
2671 | cleanup_handle (handle); | 2697 | cleanup_handle (handle); |
2672 | return; | 2698 | return; |
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 84456b386..39d24ea61 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -353,14 +353,18 @@ finished_cont (void *cls, int32_t success, const char *emsg) | |||
353 | struct MHD_Response *resp; | 353 | struct MHD_Response *resp; |
354 | 354 | ||
355 | handle->idp_op = NULL; | 355 | handle->idp_op = NULL; |
356 | resp = GNUNET_REST_create_response (emsg); | ||
357 | MHD_add_response_header (resp, "Content-Type", "application/json"); | ||
358 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | ||
359 | if (GNUNET_OK != success) | 356 | if (GNUNET_OK != success) |
360 | { | 357 | { |
361 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 358 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
362 | return; | 359 | return; |
363 | } | 360 | } |
361 | resp = GNUNET_REST_create_response (emsg); | ||
362 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, | ||
363 | "Content-Type", | ||
364 | "application/json")); | ||
365 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, | ||
366 | "Access-Control-Allow-Methods", | ||
367 | allow_methods)); | ||
364 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 368 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
365 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 369 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
366 | } | 370 | } |
@@ -372,13 +376,15 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg) | |||
372 | struct RequestHandle *handle = cls; | 376 | struct RequestHandle *handle = cls; |
373 | struct MHD_Response *resp; | 377 | struct MHD_Response *resp; |
374 | 378 | ||
375 | resp = GNUNET_REST_create_response (emsg); | ||
376 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | ||
377 | if (GNUNET_OK != success) | 379 | if (GNUNET_OK != success) |
378 | { | 380 | { |
379 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 381 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
380 | return; | 382 | return; |
381 | } | 383 | } |
384 | resp = GNUNET_REST_create_response (emsg); | ||
385 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, | ||
386 | "Access-Control-Allow-Methods", | ||
387 | allow_methods)); | ||
382 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 388 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
383 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 389 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
384 | } | 390 | } |
@@ -399,7 +405,10 @@ return_response (void *cls) | |||
399 | result_str = json_dumps (handle->resp_object, 0); | 405 | result_str = json_dumps (handle->resp_object, 0); |
400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
401 | resp = GNUNET_REST_create_response (result_str); | 407 | resp = GNUNET_REST_create_response (result_str); |
402 | MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); | 408 | GNUNET_assert (MHD_NO != |
409 | MHD_add_response_header (resp, | ||
410 | "Access-Control-Allow-Methods", | ||
411 | allow_methods)); | ||
403 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 412 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
404 | GNUNET_free (result_str); | 413 | GNUNET_free (result_str); |
405 | cleanup_handle (handle); | 414 | cleanup_handle (handle); |
@@ -461,8 +470,8 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
461 | 470 | ||
462 | static void | 471 | static void |
463 | add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | 472 | add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
464 | const char *url, | 473 | const char *url, |
465 | void *cls) | 474 | void *cls) |
466 | { | 475 | { |
467 | struct RequestHandle *handle = cls; | 476 | struct RequestHandle *handle = cls; |
468 | const struct GNUNET_IDENTITY_PrivateKey *identity_priv; | 477 | const struct GNUNET_IDENTITY_PrivateKey *identity_priv; |
@@ -513,7 +522,15 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
513 | handle->rest_handle->data, | 522 | handle->rest_handle->data, |
514 | handle->rest_handle->data_size); | 523 | handle->rest_handle->data_size); |
515 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | 524 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); |
516 | GNUNET_JSON_parse (data_json, attrspec, NULL, NULL); | 525 | if (GNUNET_OK != GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)) |
526 | { | ||
527 | json_decref (data_json); | ||
528 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
529 | "Unable to parse JSON from %s\n", | ||
530 | term_data); | ||
531 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
532 | return; | ||
533 | } | ||
517 | json_decref (data_json); | 534 | json_decref (data_json); |
518 | if (NULL == attribute) | 535 | if (NULL == attribute) |
519 | { | 536 | { |
@@ -530,11 +547,11 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
530 | GNUNET_RECLAIM_id_generate (&attribute->id); | 547 | GNUNET_RECLAIM_id_generate (&attribute->id); |
531 | exp = GNUNET_TIME_UNIT_HOURS; | 548 | exp = GNUNET_TIME_UNIT_HOURS; |
532 | handle->idp_op = GNUNET_RECLAIM_credential_store (idp, | 549 | handle->idp_op = GNUNET_RECLAIM_credential_store (idp, |
533 | identity_priv, | 550 | identity_priv, |
534 | attribute, | 551 | attribute, |
535 | &exp, | 552 | &exp, |
536 | &finished_cont, | 553 | &finished_cont, |
537 | handle); | 554 | handle); |
538 | GNUNET_JSON_parse_free (attrspec); | 555 | GNUNET_JSON_parse_free (attrspec); |
539 | } | 556 | } |
540 | 557 | ||
@@ -545,8 +562,8 @@ add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
545 | */ | 562 | */ |
546 | static void | 563 | static void |
547 | cred_collect (void *cls, | 564 | cred_collect (void *cls, |
548 | const struct GNUNET_IDENTITY_PublicKey *identity, | 565 | const struct GNUNET_IDENTITY_PublicKey *identity, |
549 | const struct GNUNET_RECLAIM_Credential *cred) | 566 | const struct GNUNET_RECLAIM_Credential *cred) |
550 | { | 567 | { |
551 | struct RequestHandle *handle = cls; | 568 | struct RequestHandle *handle = cls; |
552 | struct GNUNET_RECLAIM_AttributeList *attrs; | 569 | struct GNUNET_RECLAIM_AttributeList *attrs; |
@@ -565,8 +582,8 @@ cred_collect (void *cls, | |||
565 | attrs = GNUNET_RECLAIM_credential_get_attributes (cred); | 582 | attrs = GNUNET_RECLAIM_credential_get_attributes (cred); |
566 | issuer = GNUNET_RECLAIM_credential_get_issuer (cred); | 583 | issuer = GNUNET_RECLAIM_credential_get_issuer (cred); |
567 | tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type, | 584 | tmp_value = GNUNET_RECLAIM_credential_value_to_string (cred->type, |
568 | cred->data, | 585 | cred->data, |
569 | cred->data_size); | 586 | cred->data_size); |
570 | cred_obj = json_object (); | 587 | cred_obj = json_object (); |
571 | json_object_set_new (cred_obj, "value", json_string (tmp_value)); | 588 | json_object_set_new (cred_obj, "value", json_string (tmp_value)); |
572 | json_object_set_new (cred_obj, "name", json_string (cred->name)); | 589 | json_object_set_new (cred_obj, "name", json_string (cred->name)); |
@@ -578,7 +595,7 @@ cred_collect (void *cls, | |||
578 | GNUNET_free (issuer); | 595 | GNUNET_free (issuer); |
579 | } | 596 | } |
580 | if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred, | 597 | if (GNUNET_OK == GNUNET_RECLAIM_credential_get_expiration (cred, |
581 | &exp)) | 598 | &exp)) |
582 | { | 599 | { |
583 | json_object_set_new (cred_obj, "expiration", json_integer ( | 600 | json_object_set_new (cred_obj, "expiration", json_integer ( |
584 | exp.abs_value_us)); | 601 | exp.abs_value_us)); |
@@ -613,7 +630,8 @@ cred_collect (void *cls, | |||
613 | json_object_set_new (cred_obj, "attributes", attr_arr); | 630 | json_object_set_new (cred_obj, "attributes", attr_arr); |
614 | } | 631 | } |
615 | json_array_append_new (handle->resp_object, cred_obj); | 632 | json_array_append_new (handle->resp_object, cred_obj); |
616 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | 633 | if (NULL != attrs) |
634 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | ||
617 | GNUNET_RECLAIM_get_credentials_next (handle->cred_it); | 635 | GNUNET_RECLAIM_get_credentials_next (handle->cred_it); |
618 | } | 636 | } |
619 | 637 | ||
@@ -627,8 +645,8 @@ cred_collect (void *cls, | |||
627 | */ | 645 | */ |
628 | static void | 646 | static void |
629 | list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | 647 | list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
630 | const char *url, | 648 | const char *url, |
631 | void *cls) | 649 | void *cls) |
632 | { | 650 | { |
633 | struct RequestHandle *handle = cls; | 651 | struct RequestHandle *handle = cls; |
634 | const struct GNUNET_IDENTITY_PrivateKey *priv_key; | 652 | const struct GNUNET_IDENTITY_PrivateKey *priv_key; |
@@ -664,14 +682,14 @@ list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
664 | } | 682 | } |
665 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 683 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
666 | handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp, | 684 | handle->cred_it = GNUNET_RECLAIM_get_credentials_start (idp, |
667 | priv_key, | 685 | priv_key, |
668 | &collect_error_cb, | 686 | &collect_error_cb, |
669 | handle, | 687 | handle, |
670 | &cred_collect, | 688 | &cred_collect, |
671 | handle, | 689 | handle, |
672 | & | 690 | & |
673 | collect_finished_cb, | 691 | collect_finished_cb, |
674 | handle); | 692 | handle); |
675 | } | 693 | } |
676 | 694 | ||
677 | 695 | ||
@@ -684,8 +702,8 @@ list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
684 | */ | 702 | */ |
685 | static void | 703 | static void |
686 | delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | 704 | delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, |
687 | const char *url, | 705 | const char *url, |
688 | void *cls) | 706 | void *cls) |
689 | { | 707 | { |
690 | struct RequestHandle *handle = cls; | 708 | struct RequestHandle *handle = cls; |
691 | const struct GNUNET_IDENTITY_PrivateKey *priv_key; | 709 | const struct GNUNET_IDENTITY_PrivateKey *priv_key; |
@@ -734,10 +752,10 @@ delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
734 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); | 752 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id)); |
735 | attr.name = ""; | 753 | attr.name = ""; |
736 | handle->idp_op = GNUNET_RECLAIM_credential_delete (idp, | 754 | handle->idp_op = GNUNET_RECLAIM_credential_delete (idp, |
737 | priv_key, | 755 | priv_key, |
738 | &attr, | 756 | &attr, |
739 | &delete_finished_cb, | 757 | &delete_finished_cb, |
740 | handle); | 758 | handle); |
741 | GNUNET_free (identity_id_str); | 759 | GNUNET_free (identity_id_str); |
742 | } | 760 | } |
743 | 761 | ||
@@ -900,8 +918,8 @@ parse_jwt (const struct GNUNET_RECLAIM_Credential *cred, | |||
900 | json_error_t *json_err = NULL; | 918 | json_error_t *json_err = NULL; |
901 | 919 | ||
902 | jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type, | 920 | jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type, |
903 | cred->data, | 921 | cred->data, |
904 | cred->data_size); | 922 | cred->data_size); |
905 | char *jwt_body = strtok (jwt_string, delim); | 923 | char *jwt_body = strtok (jwt_string, delim); |
906 | jwt_body = strtok (NULL, delim); | 924 | jwt_body = strtok (NULL, delim); |
907 | GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), | 925 | GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body), |
@@ -1424,25 +1442,24 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1424 | static const struct GNUNET_REST_RequestHandler handlers[] = | 1442 | static const struct GNUNET_REST_RequestHandler handlers[] = |
1425 | { { MHD_HTTP_METHOD_GET, | 1443 | { { MHD_HTTP_METHOD_GET, |
1426 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont }, | 1444 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont }, |
1427 | { MHD_HTTP_METHOD_POST, | 1445 | { MHD_HTTP_METHOD_POST, |
1428 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &add_attribute_cont }, | 1446 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &add_attribute_cont }, |
1429 | { MHD_HTTP_METHOD_DELETE, | 1447 | { MHD_HTTP_METHOD_DELETE, |
1430 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, | 1448 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &delete_attribute_cont }, |
1431 | { MHD_HTTP_METHOD_GET, | 1449 | { MHD_HTTP_METHOD_GET, |
1432 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont }, | 1450 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &list_credential_cont }, |
1433 | { MHD_HTTP_METHOD_POST, | 1451 | { MHD_HTTP_METHOD_POST, |
1434 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont }, | 1452 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &add_credential_cont }, |
1435 | { MHD_HTTP_METHOD_DELETE, | 1453 | { MHD_HTTP_METHOD_DELETE, |
1436 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont }, | 1454 | GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, &delete_credential_cont }, |
1437 | { MHD_HTTP_METHOD_GET, | 1455 | { MHD_HTTP_METHOD_GET, |
1438 | GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, | 1456 | GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont }, |
1439 | { MHD_HTTP_METHOD_POST, | 1457 | { MHD_HTTP_METHOD_POST, |
1440 | GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont }, | 1458 | GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont }, |
1441 | { MHD_HTTP_METHOD_POST, | 1459 | { MHD_HTTP_METHOD_POST, |
1442 | GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont }, | 1460 | GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont }, |
1443 | { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont }, | 1461 | { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont }, |
1444 | GNUNET_REST_HANDLER_END | 1462 | GNUNET_REST_HANDLER_END}; |
1445 | }; | ||
1446 | 1463 | ||
1447 | handle->response_code = 0; | 1464 | handle->response_code = 0; |
1448 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1465 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index f4f2b946a..c08cc868c 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -651,18 +651,15 @@ handle_consume_ticket_result (void *cls, | |||
651 | le->attribute, NULL); | 651 | le->attribute, NULL); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | if (NULL != attrs) | ||
655 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | ||
656 | if (NULL != pl) | ||
657 | GNUNET_RECLAIM_presentation_list_destroy (pl); | ||
658 | attrs = NULL; | ||
659 | pl = NULL; | ||
660 | } | 654 | } |
661 | op->atr_cb (op->cls, NULL, NULL, NULL); | 655 | op->atr_cb (op->cls, NULL, NULL, NULL); |
662 | } | 656 | } |
657 | if (NULL != attrs) | ||
658 | GNUNET_RECLAIM_attribute_list_destroy (attrs); | ||
659 | if (NULL != pl) | ||
660 | GNUNET_RECLAIM_presentation_list_destroy (pl); | ||
663 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 661 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); |
664 | free_op (op); | 662 | free_op (op); |
665 | GNUNET_free (attrs); | ||
666 | return; | 663 | return; |
667 | } | 664 | } |
668 | GNUNET_assert (0); | 665 | GNUNET_assert (0); |
@@ -804,7 +801,7 @@ check_credential_result (void *cls, const struct CredentialResultMessage *msg) | |||
804 | */ | 801 | */ |
805 | static void | 802 | static void |
806 | handle_credential_result (void *cls, const struct | 803 | handle_credential_result (void *cls, const struct |
807 | CredentialResultMessage *msg) | 804 | CredentialResultMessage *msg) |
808 | { | 805 | { |
809 | static struct GNUNET_IDENTITY_PrivateKey identity_dummy; | 806 | static struct GNUNET_IDENTITY_PrivateKey identity_dummy; |
810 | struct GNUNET_RECLAIM_Handle *h = cls; | 807 | struct GNUNET_RECLAIM_Handle *h = cls; |
@@ -871,6 +868,7 @@ handle_credential_result (void *cls, const struct | |||
871 | GNUNET_assert (0); | 868 | GNUNET_assert (0); |
872 | } | 869 | } |
873 | 870 | ||
871 | |||
874 | /** | 872 | /** |
875 | * Handle an incoming message of type | 873 | * Handle an incoming message of type |
876 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT | 874 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT |
@@ -925,7 +923,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
925 | if (NULL != op) | 923 | if (NULL != op) |
926 | { | 924 | { |
927 | if (0 < pres_len) | 925 | if (0 < pres_len) |
928 | pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1], | 926 | pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*) &msg[1], |
929 | pres_len); | 927 | pres_len); |
930 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); | 928 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); |
931 | if (0 == | 929 | if (0 == |
@@ -1485,7 +1483,7 @@ GNUNET_RECLAIM_get_credentials_start ( | |||
1485 | */ | 1483 | */ |
1486 | void | 1484 | void |
1487 | GNUNET_RECLAIM_get_credentials_next (struct | 1485 | GNUNET_RECLAIM_get_credentials_next (struct |
1488 | GNUNET_RECLAIM_CredentialIterator *ait) | 1486 | GNUNET_RECLAIM_CredentialIterator *ait) |
1489 | { | 1487 | { |
1490 | struct GNUNET_RECLAIM_Handle *h = ait->h; | 1488 | struct GNUNET_RECLAIM_Handle *h = ait->h; |
1491 | struct CredentialIterationNextMessage *msg; | 1489 | struct CredentialIterationNextMessage *msg; |
@@ -1507,7 +1505,7 @@ GNUNET_RECLAIM_get_credentials_next (struct | |||
1507 | */ | 1505 | */ |
1508 | void | 1506 | void |
1509 | GNUNET_RECLAIM_get_credentials_stop (struct | 1507 | GNUNET_RECLAIM_get_credentials_stop (struct |
1510 | GNUNET_RECLAIM_CredentialIterator *ait) | 1508 | GNUNET_RECLAIM_CredentialIterator *ait) |
1511 | { | 1509 | { |
1512 | struct GNUNET_RECLAIM_Handle *h = ait->h; | 1510 | struct GNUNET_RECLAIM_Handle *h = ait->h; |
1513 | struct GNUNET_MQ_Envelope *env; | 1511 | struct GNUNET_MQ_Envelope *env; |