diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange/taler-exchange-httpd_age-withdraw.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_age-withdraw_reveal.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refreshes_reveal.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_get_age_withdraw.c | 10 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 54 | ||||
-rw-r--r-- | src/util/age_restriction.c | 2 |
6 files changed, 58 insertions, 40 deletions
diff --git a/src/exchange/taler-exchange-httpd_age-withdraw.c b/src/exchange/taler-exchange-httpd_age-withdraw.c index 56065dda8..bcbb71563 100644 --- a/src/exchange/taler-exchange-httpd_age-withdraw.c +++ b/src/exchange/taler-exchange-httpd_age-withdraw.c @@ -231,11 +231,17 @@ parse_age_withdraw_json ( json_array_foreach (j_kappa_coin_evs, kappa, value) { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_blinded_planchet (NULL, &awc->coin_evs[off + kappa]), + /* FIXME-Oec: This allocation is never freed! */ + TALER_JSON_spec_blinded_planchet (NULL, + &awc->coin_evs[off + kappa]), GNUNET_JSON_spec_end () }; + if (GNUNET_OK != - GNUNET_JSON_parse (value, spec, NULL, NULL)) + GNUNET_JSON_parse (value, + spec, + NULL, + NULL)) { GNUNET_snprintf (buf, sizeof(buf), @@ -249,12 +255,11 @@ parse_age_withdraw_json ( /* Continue to hash of the coin candidates */ { struct TALER_BlindedCoinHashP bch; + ret = TALER_coin_ev_hash (&awc->coin_evs[off + kappa], &awc->denom_hs[idx], &bch); - GNUNET_assert (GNUNET_OK == ret); - GNUNET_CRYPTO_hash_context_read (hash_context, &bch, sizeof(bch)); @@ -830,7 +835,7 @@ age_withdraw_transaction (void *cls, * @param connection HTTP-connection to the client * @param awc The context for the current age withdraw request * @param[out] result On error, a HTTP-response will be queued and result set accordingly - * @return GNUNET_OK on success, GNUNET_SYSERR otherwise + * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise */ static enum GNUNET_GenericReturnValue sign_and_do_age_withdraw ( diff --git a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c index 7463d2225..9b9f1cb88 100644 --- a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c +++ b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c @@ -194,8 +194,8 @@ EXIT: * @param reserve_pub Reserve public key used in the original age-withdraw request * @param[out] commitment Data from the original age-withdraw request * @param[out] result In the error cases, a response will be queued with MHD and this will be the result. - * @return GNUNET_OK if the withdraw request has been found, - * GNUNET_SYSERROR if we did not find the request in the DB + * @return #GNUNET_OK if the withdraw request has been found, + * #GNUNET_SYSERR if we did not find the request in the DB */ static enum GNUNET_GenericReturnValue find_original_commitment ( @@ -217,20 +217,17 @@ find_original_commitment ( { case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return GNUNET_OK; /* Only happy case */ - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: *result = TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, TALER_EC_EXCHANGE_AGE_WITHDRAW_COMMITMENT_UNKNOWN, NULL); return GNUNET_SYSERR; - case GNUNET_DB_STATUS_HARD_ERROR: *result = TALER_MHD_reply_with_ec (connection, TALER_EC_GENERIC_DB_FETCH_FAILED, "get_age_withdraw_info"); return GNUNET_SYSERR; - case GNUNET_DB_STATUS_SOFT_ERROR: break; /* try again */ default: @@ -300,6 +297,7 @@ calculate_blinded_hash ( &acp); TALER_age_commitment_hash (&acp.commitment, &ach); + TALER_age_commitment_proof_free (&acp); } /* Next: calculate planchet */ @@ -362,7 +360,7 @@ calculate_blinded_hash ( ret = TALER_coin_ev_hash (&detail.blinded_planchet, &denom_key->h_denom_pub, bch); - + TALER_blinded_planchet_free (&detail.blinded_planchet); GNUNET_assert (GNUNET_OK == ret); } @@ -599,6 +597,11 @@ TEH_handler_age_withdraw_reveal ( } while(0); GNUNET_JSON_parse_free (spec); + for (unsigned int i = 0; i<actx.num_coins; i++) + TALER_blinded_denom_sig_free (&actx.commitment.denom_sigs[i]); + GNUNET_free (actx.commitment.denom_sigs); + GNUNET_free (actx.commitment.denom_pub_hashes); + GNUNET_free (actx.commitment.denom_serials); GNUNET_free (actx.disclosed_coin_secrets); return result; } diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index 0509bc90a..5630051cf 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -314,9 +314,9 @@ check_commitment (struct RevealContext *rctx, &acp, &ts.key, &nacp)); - TALER_age_commitment_hash (&nacp.commitment, &h); + TALER_age_commitment_proof_free (&nacp); hac = &h; } diff --git a/src/exchangedb/pg_get_age_withdraw.c b/src/exchangedb/pg_get_age_withdraw.c index 6247fd14f..9a80f189b 100644 --- a/src/exchangedb/pg_get_age_withdraw.c +++ b/src/exchangedb/pg_get_age_withdraw.c @@ -61,22 +61,16 @@ TEH_PG_get_age_withdraw ( TALER_PQ_result_spec_array_blinded_denom_sig ( pg->conn, "denom_sigs", - NULL, /* we assume that this is the same size as h_coin_evs */ + NULL, /* FIXME-Oec: this assumes that this is the same size as h_coin_evs, but we should check! */ &aw->denom_sigs), TALER_PQ_result_spec_array_denom_hash ( pg->conn, "denom_pub_hashes", - NULL, /* we assume that this is the same size as h_coin_evs */ + NULL, /* FIXME-Oec: this assumes that this is the same size as h_coin_evs, but we should check! */ &aw->denom_pub_hashes), GNUNET_PQ_result_spec_end }; - GNUNET_assert (NULL != aw); - - /* Used in #postgres_get_age_withdraw() to - locate the response for a /reserve/$RESERVE_PUB/age-withdraw request - using the hash of the blinded message. Also needed to ensure - idempotency of /reserve/$RESERVE_PUB/age-withdraw requests. */ PREPARE (pg, "get_age_withdraw", "SELECT" diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index c32e0d0e8..6f4338666 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c @@ -1068,29 +1068,44 @@ TALER_PQ_result_spec_exchange_withdraw_values ( */ struct ArrayResultCls { - /* Oid of the expected type, must match the oid in the header of the PQResult struct */ + /** + * Oid of the expected type, must match the oid in the header of the PQResult struct + */ Oid oid; - /* Target type */ + /** + * Target type + */ enum TALER_PQ_ArrayType typ; - /* If not 0, defines the expected size of each entry */ + /** + * If not 0, defines the expected size of each entry + */ size_t same_size; - /* Out-pointer to write the number of elements in the array */ + /** + * Out-pointer to write the number of elements in the array + */ size_t *num; - /* Out-pointer. If @a typ is TALER_PQ_array_of_byte and @a same_size is 0, - * allocate and put the array of @a num sizes here. NULL otherwise */ + /** + * Out-pointer. If @a typ is TALER_PQ_array_of_byte and @a same_size is 0, + * allocate and put the array of @a num sizes here. NULL otherwise + */ size_t **sizes; - /* DB_connection, needed for OID-lookup for composite types */ + /** + * DB_connection, needed for OID-lookup for composite types + */ const struct GNUNET_PQ_Context *db; - /* Currency information for amount composites */ + /** + * Currency information for amount composites + */ char currency[TALER_CURRENCY_LEN]; }; + /** * Extract data from a Postgres database @a result as array of a specific type * from row @a row. The type information and optionally additional @@ -1175,7 +1190,8 @@ extract_array_generic ( if (NULL != dst_size) *dst_size = sizeof(struct TALER_Amount) * (header.dim); - amounts = GNUNET_new_array (header.dim, struct TALER_Amount); + amounts = GNUNET_new_array (header.dim, + struct TALER_Amount); *((void **) dst) = amounts; for (uint32_t i = 0; i < header.dim; i++) @@ -1212,7 +1228,8 @@ extract_array_generic ( case TALER_PQ_array_of_denom_hash: if (NULL != dst_size) *dst_size = sizeof(struct TALER_DenominationHashP) * (header.dim); - out = GNUNET_new_array (header.dim, struct TALER_DenominationHashP); + out = GNUNET_new_array (header.dim, + struct TALER_DenominationHashP); *((void **) dst) = out; for (uint32_t i = 0; i < header.dim; i++) { @@ -1235,7 +1252,8 @@ extract_array_generic ( case TALER_PQ_array_of_blinded_coin_hash: if (NULL != dst_size) *dst_size = sizeof(struct TALER_BlindedCoinHashP) * (header.dim); - out = GNUNET_new_array (header.dim, struct TALER_BlindedCoinHashP); + out = GNUNET_new_array (header.dim, + struct TALER_BlindedCoinHashP); *((void **) dst) = out; for (uint32_t i = 0; i < header.dim; i++) { @@ -1294,12 +1312,13 @@ extract_array_generic ( sz -= sizeof(be); bs = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature); bs->cipher = ntohl (be[0]); + bs->rc = 1; switch (bs->cipher) { case GNUNET_CRYPTO_BSA_RSA: - bs->details.blinded_rsa_signature = - GNUNET_CRYPTO_rsa_signature_decode (in, - sz); + bs->details.blinded_rsa_signature + = GNUNET_CRYPTO_rsa_signature_decode (in, + sz); if (NULL == bs->details.blinded_rsa_signature) { GNUNET_free (bs); @@ -1329,12 +1348,10 @@ extract_array_generic ( FAIL_IF (true); } } - FAIL: GNUNET_free (*(void **) dst); return GNUNET_SYSERR; - #undef FAIL_IF - +#undef FAIL_IF } @@ -1345,10 +1362,11 @@ static void array_cleanup (void *cls, void *rd) { - struct ArrayResultCls *info = cls; void **dst = rd; + /* FIXME-Oec: this does not properly clean up + denomination signatures! */ if ((0 == info->same_size) && (NULL != info->sizes)) GNUNET_free (*(info->sizes)); diff --git a/src/util/age_restriction.c b/src/util/age_restriction.c index 883ae5e9a..f79c767a9 100644 --- a/src/util/age_restriction.c +++ b/src/util/age_restriction.c @@ -671,11 +671,9 @@ TALER_age_restriction_from_secret ( ncp->commitment.num = num_pub; ncp->proof.num = num_priv; ncp->proof.keys = NULL; - ncp->commitment.keys = GNUNET_new_array ( num_pub, struct TALER_AgeCommitmentPublicKeyP); - if (0 < num_priv) ncp->proof.keys = GNUNET_new_array ( num_priv, |