patch from Lucien

This commit is contained in:
Christian Grothoff 2022-02-08 22:58:02 +01:00
parent 4076712210
commit 6cbf7218d8
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -39,6 +39,7 @@ TEH_handler_csr (struct TEH_RequestContext *rc,
{ {
unsigned int csr_requests_num; unsigned int csr_requests_num;
json_t *csr_requests; json_t *csr_requests;
json_t *csr_response_ewvs;
json_t *csr_response; json_t *csr_response;
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification spec[] = {
@ -58,13 +59,13 @@ TEH_handler_csr (struct TEH_RequestContext *rc,
res = TALER_MHD_parse_json_data (rc->connection, res = TALER_MHD_parse_json_data (rc->connection,
root, root,
spec); spec);
GNUNET_JSON_parse_free (spec);
if (GNUNET_OK != res) if (GNUNET_OK != res)
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
} }
csr_requests_num = json_array_size (csr_requests); csr_requests_num = json_array_size (csr_requests);
if (TALER_MAX_FRESH_COINS <= csr_requests_num) if (TALER_MAX_FRESH_COINS <= csr_requests_num)
{ {
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error ( return TALER_MHD_reply_with_error (
rc->connection, rc->connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
@ -90,13 +91,17 @@ TEH_handler_csr (struct TEH_RequestContext *rc,
enum GNUNET_GenericReturnValue res; enum GNUNET_GenericReturnValue res;
res = TALER_MHD_parse_json_array (rc->connection, res = TALER_MHD_parse_json_array (rc->connection,
root, csr_requests,
csr_spec, csr_spec,
i, i,
-1); -1);
if (GNUNET_OK != res) if (GNUNET_OK != res)
{
GNUNET_JSON_parse_free (spec);
return (GNUNET_NO == res) ? MHD_YES : MHD_NO; return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
} }
}
GNUNET_JSON_parse_free (spec);
struct TALER_DenominationCSPublicRPairP r_pubs[GNUNET_NZL (csr_requests_num)]; struct TALER_DenominationCSPublicRPairP r_pubs[GNUNET_NZL (csr_requests_num)];
for (unsigned int i = 0; i < csr_requests_num; i++) for (unsigned int i = 0; i < csr_requests_num; i++)
@ -179,7 +184,7 @@ TEH_handler_csr (struct TEH_RequestContext *rc,
} }
// send response // send response
csr_response = json_array (); csr_response_ewvs = json_array ();
for (unsigned int i = 0; i < csr_requests_num; i++) for (unsigned int i = 0; i < csr_requests_num; i++)
{ {
const struct TALER_DenominationCSPublicRPairP *r_pub = &r_pubs[i]; const struct TALER_DenominationCSPublicRPairP *r_pub = &r_pubs[i];
@ -194,9 +199,14 @@ TEH_handler_csr (struct TEH_RequestContext *rc,
sizeof(struct GNUNET_CRYPTO_CsRPublic))); sizeof(struct GNUNET_CRYPTO_CsRPublic)));
GNUNET_assert (NULL != csr_obj); GNUNET_assert (NULL != csr_obj);
GNUNET_assert (0 == GNUNET_assert (0 ==
json_array_append_new (csr_response, json_array_append_new (csr_response_ewvs,
csr_obj)); csr_obj));
} }
csr_response = GNUNET_JSON_PACK (
GNUNET_JSON_pack_array_steal ("ewvs",
csr_response_ewvs));
GNUNET_assert (NULL != csr_response);
return TALER_MHD_reply_json (rc->connection, return TALER_MHD_reply_json (rc->connection,
csr_response, csr_response,
MHD_HTTP_OK); MHD_HTTP_OK);