summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-11 18:22:33 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-11 18:22:33 +0200
commit766fb6e2821dc84ccfe290e8906f12001e34043b (patch)
tree6db1e23ca9402076b9390a662b79f101ec58f750 /src/exchange
parentf4b013b3d467f93482a00b208acf3a2874362fe7 (diff)
downloadexchange-766fb6e2821dc84ccfe290e8906f12001e34043b.tar.gz
exchange-766fb6e2821dc84ccfe290e8906f12001e34043b.tar.bz2
exchange-766fb6e2821dc84ccfe290e8906f12001e34043b.zip
fixing more leaks
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-aggregator.c8
-rw-r--r--src/exchange/taler-exchange-httpd_db.c50
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c3
-rw-r--r--src/exchange/taler-exchange-httpd_wire.c23
4 files changed, 59 insertions, 25 deletions
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index e3262962c..d7b216e5f 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -432,12 +432,11 @@ deposit_cb (void *cls,
return GNUNET_SYSERR;
}
au->row_id = row_id;
- au->wire = (json_t *) wire;
+ au->wire = json_incref ((json_t *) wire);
au->execution_time = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&au->execution_time);
TALER_JSON_hash (au->wire,
&au->h_wire);
- json_incref (au->wire);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&au->wtid,
sizeof (au->wtid));
@@ -774,8 +773,8 @@ run_aggregation (void *cls)
GNUNET_free_non_null (au->additional_rows);
if (NULL != au->wire)
json_decref (au->wire);
- au = NULL;
GNUNET_free (au);
+ au = NULL;
/* start again */
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
NULL);
@@ -810,7 +809,10 @@ prepare_cb (void *cls,
struct TALER_EXCHANGEDB_Session *session = au->session;
if (NULL != au->wire)
+ {
json_decref (au->wire);
+ au->wire = NULL;
+ }
GNUNET_free_non_null (au->additional_rows);
if (NULL == buf)
{
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 4cd3df490..1ba64b2a2 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -1185,6 +1185,7 @@ check_commitment (struct MHD_Connection *connection,
struct TALER_TransferPublicKeyP transfer_pub_check;
struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins;
unsigned int j;
+ int ret;
if (GNUNET_OK !=
TMH_plugin->get_refresh_commit_link (TMH_plugin->cls,
@@ -1271,10 +1272,10 @@ check_commitment (struct MHD_Connection *connection,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Blind failed (bad denomination key!?)\n");
- GNUNET_free (commit_coins);
- return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
+ ret = (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
"Blinding error"))
? GNUNET_NO : GNUNET_SYSERR;
+ goto cleanup;
}
if ( (buf_len != commit_coins[j].coin_ev_size) ||
@@ -1286,20 +1287,25 @@ check_commitment (struct MHD_Connection *connection,
"blind envelope does not match for k=%u, old=%d\n",
off,
(int) j);
- GNUNET_free (commit_coins);
- return send_melt_commitment_error (connection,
- session,
- session_hash,
- melt,
- off,
- j,
- "envelope");
+ GNUNET_free (buf);
+ ret = send_melt_commitment_error (connection,
+ session,
+ session_hash,
+ melt,
+ off,
+ j,
+ "envelope");
+ goto cleanup;
}
GNUNET_free (buf);
}
- GNUNET_free (commit_coins);
+ ret = GNUNET_OK;
- return GNUNET_OK;
+ cleanup:
+ for (j = 0; j < num_newcoins; j++)
+ GNUNET_free (commit_coins[j].coin_ev);
+ GNUNET_free (commit_coins);
+ return ret;
}
@@ -1390,6 +1396,7 @@ execute_refresh_reveal_transaction (struct MHD_Connection *connection,
{
unsigned int j;
struct TMH_KS_StateHandle *key_state;
+ int ret;
START_TRANSACTION (session, connection);
if (GNUNET_OK !=
@@ -1416,15 +1423,17 @@ execute_refresh_reveal_transaction (struct MHD_Connection *connection,
j);
if (NULL == ev_sigs[j].rsa_signature)
{
- TMH_KS_release (key_state);
- return TMH_RESPONSE_reply_internal_db_error (connection);
+ ret = TMH_RESPONSE_reply_internal_db_error (connection);
+ goto cleanup;
}
}
- TMH_KS_release (key_state);
COMMIT_TRANSACTION (session, connection);
- return TMH_RESPONSE_reply_refresh_reveal_success (connection,
- refresh_session->num_newcoins,
- ev_sigs);
+ ret = TMH_RESPONSE_reply_refresh_reveal_success (connection,
+ refresh_session->num_newcoins,
+ ev_sigs);
+ cleanup:
+ TMH_KS_release (key_state);
+ return ret;
}
@@ -1526,8 +1535,11 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
ev_sigs,
commit_coins);
for (i=0;i<refresh_session.num_newcoins;i++)
+ {
if (NULL != ev_sigs[i].rsa_signature)
- GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
+ GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
+ GNUNET_free (commit_coins[i].coin_ev);
+ }
for (j=0;j<refresh_session.num_newcoins;j++)
if (NULL != denom_pubs[j].rsa_public_key)
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 0c296d942..e0e5c2d65 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -66,7 +66,8 @@ TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
json_str = json_dumps (json, JSON_INDENT(2));
GNUNET_assert (NULL != json_str);
- resp = MHD_create_response_from_buffer (strlen (json_str), json_str,
+ resp = MHD_create_response_from_buffer (strlen (json_str),
+ json_str,
MHD_RESPMEM_MUST_FREE);
if (NULL == resp)
{
diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c
index 79e69cc13..372e39bb6 100644
--- a/src/exchange/taler-exchange-httpd_wire.c
+++ b/src/exchange/taler-exchange-httpd_wire.c
@@ -27,6 +27,12 @@
#include <jansson.h>
/**
+ * Cached JSON for /wire response.
+ */
+static json_t *wire_methods;
+
+
+/**
* Handle a "/wire" request.
*
* @param rh context of the handler
@@ -43,8 +49,6 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
- static json_t *wire_methods;
-
if (NULL == wire_methods)
wire_methods = TMH_VALIDATION_get_wire_methods ("exchange-wire-incoming");
@@ -54,4 +58,19 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh,
}
+/**
+ * Initialize libgcrypt.
+ */
+void __attribute__ ((destructor))
+TEH_wire_cleanup ()
+{
+ if (NULL != wire_methods)
+ {
+ json_decref (wire_methods);
+ wire_methods = NULL;
+ }
+}
+
+
+
/* end of taler-exchange-httpd_wire.c */