aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-17 16:57:29 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-17 16:57:29 +0100
commit86e0f2c70d07c7c5e1656667bd818498ea55d0a4 (patch)
treedba9439c62d1b017319d9e313a82b33ea6c68187 /src
parent87a78c6f8ce1d50a5f61eb5c3f222cdef0b635ee (diff)
fix memory leak and transaction error handling related to KYC
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-aggregator.c3
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-wallet.c3
-rw-r--r--src/exchange/taler-exchange-httpd_purses_merge.c15
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_close.c15
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_purse.c16
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c14
-rw-r--r--src/include/taler_kyclogic_lib.h2
-rw-r--r--src/kyclogic/kyclogic_api.c2
8 files changed, 57 insertions, 13 deletions
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index d196ff268..7244c5ec3 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -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;
}
diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c
index 515d84b69..e56204ef5 100644
--- a/src/exchange/taler-exchange-httpd_kyc-wallet.c
+++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c
@@ -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);
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c
index 174131a3b..d246263f1 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -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 (
diff --git a/src/exchange/taler-exchange-httpd_reserves_close.c b/src/exchange/taler-exchange-httpd_reserves_close.c
index 29c08ff72..760f705c6 100644
--- a/src/exchange/taler-exchange-httpd_reserves_close.c
+++ b/src/exchange/taler-exchange-httpd_reserves_close.c
@@ -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;
}
}
diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c b/src/exchange/taler-exchange-httpd_reserves_purse.c
index d62c1db9b..5e39f810f 100644
--- a/src/exchange/taler-exchange-httpd_reserves_purse.c
+++ b/src/exchange/taler-exchange-httpd_reserves_purse.c
@@ -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;
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 40cefc7dc..9560e7dc0 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -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;
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 065f25618..98233b359 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -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);
/**
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index b82a6c065..e1aff0204 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -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;