donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit aaea91fbedb5c815c24f8efeee15ac00c0248dc9
parent 6a64d4fc12767a7fcd01c004c2fe956d480d388a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 25 Oct 2025 22:02:47 +0200

fix leaks (#10505)

Diffstat:
Msrc/donau/donau-httpd_batch-issue.c | 50++++++++++++++++++++++++++++++++++++++++++++++----
Msrc/donaudb/pg_insert_submitted_receipts.c | 1+
Msrc/pq/pq_query_helper.c | 7++++---
3 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/src/donau/donau-httpd_batch-issue.c b/src/donau/donau-httpd_batch-issue.c @@ -68,6 +68,27 @@ parse_json_bkp (struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkp, /** + * Free @a bkps array. + * + * @param num_bkps length of the array + * @param[in] bkps array to release + */ +static void +free_bkps (size_t num_bkps, + struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps) +{ + for (unsigned int i = 0; i<num_bkps; i++) + { + struct DONAU_BlindedUniqueDonorIdentifier *budi = &bkps[i].blinded_udi; + + if (NULL != budi->blinded_message) + GNUNET_CRYPTO_blinded_message_decref (budi->blinded_message); + } + GNUNET_free (bkps); +} + + +/** * Parse signatures to JSON. * * @param num_sig number of signatures @@ -84,6 +105,7 @@ signatures_to_json (const size_t num_sig, for (size_t i = 0; i < num_sig; i++) { struct DONAU_BlindedDonationUnitSignature *signature = &signatures[i]; + GNUNET_assert ( 0 == json_array_append ( j_signatures, @@ -164,9 +186,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, } - bkps = GNUNET_new_array - (num_bkps, - struct DONAU_BlindedUniqueDonorIdentifierKeyPair); + bkps = GNUNET_new_array (num_bkps, + struct DONAU_BlindedUniqueDonorIdentifierKeyPair); { json_t *bkp_obj; size_t index; @@ -180,6 +201,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, bkp_obj)) { GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -199,12 +222,16 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_FETCH_FAILED, NULL); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_NOT_FOUND, @@ -224,6 +251,8 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, &charity_sig)) { GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_FORBIDDEN, @@ -285,6 +314,8 @@ start: case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_FETCH_FAILED, @@ -299,6 +330,8 @@ start: signatures_to_json (num_bkps, check_receipts_meta.blinded_sig, blind_signatures); + free_bkps (num_bkps, + bkps); return TALER_MHD_REPLY_JSON_PACK ( rc->connection, MHD_HTTP_OK, @@ -322,6 +355,8 @@ start: &bkps[i].h_donation_unit_pub))) { GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_NOT_FOUND, TALER_EC_DONAU_GENERIC_KEYS_MISSING, @@ -329,7 +364,8 @@ start: } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "public key value: %lu.%u\n", - dk->value.value, dk->value.fraction); + dk->value.value, + dk->value.fraction); GNUNET_assert (0 <= TALER_amount_add (&receipts_sum, &receipts_sum, &dk->value)); @@ -354,6 +390,8 @@ start: if (TALER_EC_NONE != batch_sign_ec) { GNUNET_break_op (0); + free_bkps (num_bkps, + bkps); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, batch_sign_ec, @@ -361,6 +399,8 @@ start: } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "made blind signatures!\n"); + free_bkps (num_bkps, + bkps); /* save new receipts to date and save receipts Request (blinded signatures, * charity id, amount, hash over bkps) to make it idempotent*/ @@ -402,6 +442,8 @@ start: signatures_to_json (num_bkps, du_sigs, blind_signatures); + for (unsigned int i = 0; i<num_bkps; i++) + GNUNET_CRYPTO_blinded_sig_decref (du_sigs[i].blinded_sig); } return TALER_MHD_REPLY_JSON_PACK ( rc->connection, diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c @@ -96,5 +96,6 @@ DH_PG_insert_submitted_receipts ( i); } } + GNUNET_PQ_cleanup_result (rs); return qs; } diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c @@ -343,9 +343,10 @@ qconv_array ( const struct DONAU_DonationUnitSignature *du_sigs = data; size_t len; - buffers = GNUNET_new_array (num, void *); - buffer_lengths = GNUNET_new_array (num, size_t); - + buffers = GNUNET_new_array (num, + void *); + buffer_lengths = GNUNET_new_array (num, + size_t); for (size_t i = 0; i<num; i++) { const struct GNUNET_CRYPTO_UnblindedSignature *ubs =