fix memory leak and transaction error handling related to KYC

This commit is contained in:
Christian Grothoff 2023-02-17 16:57:29 +01:00
parent 87a78c6f8c
commit 86e0f2c70d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 57 additions and 13 deletions

View File

@ -496,7 +496,7 @@ return_relevant_amounts (void *cls,
static bool
kyc_satisfied (struct AggregationUnit *au_active)
{
const char *requirement;
char *requirement;
enum GNUNET_DB_QueryStatus qs;
qs = TALER_KYCLOGIC_kyc_test_required (
@ -535,6 +535,7 @@ kyc_satisfied (struct AggregationUnit *au_active)
"Legitimization process %llu started\n",
(unsigned long long) au_active->requirement_row);
}
GNUNET_free (requirement);
return false;
}

View File

@ -54,7 +54,7 @@ struct KycRequestContext
/**
* Name of the required check.
*/
const char *required;
char *required;
};
@ -237,6 +237,7 @@ TEH_handler_kyc_wallet (
NULL,
0);
}
GNUNET_free (kyc.required);
return TEH_RESPONSE_reply_kyc_required (rc->connection,
&krc.h_payto,
&krc.kyc);

View File

@ -280,7 +280,7 @@ merge_transaction (void *cls,
bool in_conflict = true;
bool no_balance = true;
bool no_partner = true;
const char *required;
char *required;
qs = TALER_KYCLOGIC_kyc_test_required (
TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE,
@ -305,11 +305,22 @@ merge_transaction (void *cls,
if (NULL != required)
{
pcc->kyc.ok = false;
return TEH_plugin->insert_kyc_requirement_for_account (
qs = TEH_plugin->insert_kyc_requirement_for_account (
TEH_plugin->cls,
required,
&pcc->h_payto,
&pcc->kyc.requirement_row);
GNUNET_free (required);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_break (0);
*mhd_ret
= TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
"insert_kyc_requirement_for_account");
}
return qs;
}
pcc->kyc.ok = true;
qs = TEH_plugin->do_purse_merge (

View File

@ -228,7 +228,7 @@ reserve_close_transaction (void *cls,
/* KYC check may be needed: we're not returning
the money to the account that funded the reserve
in the first place. */
const char *kyc_needed;
char *kyc_needed;
TALER_payto_hash (rcc->payto_uri,
&rcc->kyc_payto);
@ -268,11 +268,22 @@ reserve_close_transaction (void *cls,
if (NULL != kyc_needed)
{
rcc->kyc.ok = false;
return TEH_plugin->insert_kyc_requirement_for_account (
qs = TEH_plugin->insert_kyc_requirement_for_account (
TEH_plugin->cls,
kyc_needed,
&rcc->kyc_payto,
&rcc->kyc.requirement_row);
GNUNET_free (kyc_needed);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_break (0);
*mhd_ret
= TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
"insert_kyc_requirement_for_account");
}
return qs;
}
}

View File

@ -189,8 +189,7 @@ purse_transaction (void *cls,
{
struct ReservePurseContext *rpc = cls;
enum GNUNET_DB_QueryStatus qs;
const char *required;
char *required;
qs = TALER_KYCLOGIC_kyc_test_required (
TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE,
@ -215,11 +214,22 @@ purse_transaction (void *cls,
if (NULL != required)
{
rpc->kyc.ok = false;
return TEH_plugin->insert_kyc_requirement_for_account (
qs = TEH_plugin->insert_kyc_requirement_for_account (
TEH_plugin->cls,
required,
&rpc->h_payto,
&rpc->kyc.requirement_row);
GNUNET_free (required);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_break (0);
*mhd_ret
= TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
"insert_kyc_requirement_for_account");
}
return qs;
}
rpc->kyc.ok = true;

View File

@ -288,7 +288,7 @@ withdraw_transaction (void *cls,
is required as the merge already did that. */
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
{
const char *kyc_required;
char *kyc_required;
qs = TALER_KYCLOGIC_kyc_test_required (
TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW,
@ -314,11 +314,21 @@ withdraw_transaction (void *cls,
{
/* insert KYC requirement into DB! */
wc->kyc.ok = false;
return TEH_plugin->insert_kyc_requirement_for_account (
qs = TEH_plugin->insert_kyc_requirement_for_account (
TEH_plugin->cls,
kyc_required,
&wc->h_account_payto,
&wc->kyc.requirement_row);
GNUNET_free (kyc_required);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_break (0);
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
"insert_kyc_requirement_for_account");
}
return qs;
}
}
wc->kyc.ok = true;

View File

@ -225,7 +225,7 @@ TALER_KYCLOGIC_kyc_test_required (enum TALER_KYCLOGIC_KycTriggerEvent event,
void *ki_cls,
TALER_KYCLOGIC_KycAmountIterator ai,
void *ai_cls,
const char **required);
char **required);
/**

View File

@ -1064,7 +1064,7 @@ TALER_KYCLOGIC_kyc_test_required (enum TALER_KYCLOGIC_KycTriggerEvent event,
void *ki_cls,
TALER_KYCLOGIC_KycAmountIterator ai,
void *ai_cls,
const char **required)
char **required)
{
struct TALER_KYCLOGIC_KycCheck *needed[num_kyc_checks];
unsigned int needed_cnt = 0;