aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-19 22:23:57 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-19 22:24:04 +0100
commite46467510daf1dc55b9d01fcca42eb9912492133 (patch)
tree34b5a30b977ae003afe5b8f55d2ab58ee9d40ffa
parent12468e1fd89748aaa4b1d31052e97e2436b763c4 (diff)
leak fixes
-rw-r--r--src/benchmark/taler-exchange-benchmark.c64
-rw-r--r--src/exchange/test_taler_exchange_httpd_afl.sh13
-rw-r--r--src/lib/exchange_api_handle.c1
-rw-r--r--src/testing/testing_api_cmd_withdraw.c24
4 files changed, 70 insertions, 32 deletions
diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c
index 38ba810fa..bd4d3eafe 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -176,14 +176,48 @@ static char *remote_host;
static char *remote_dir;
/**
+ * Array of command labels.
+ */
+static char **labels;
+
+/**
+ * Length of #labels.
+ */
+static unsigned int label_len;
+
+/**
+ * Offset in #labels.
+ */
+static unsigned int label_off;
+
+/**
* Don't kill exchange/fakebank/wirewatch until
* requested by the user explicitly.
*/
static int linger;
+/**
+ * Add label to the #labels table and return it.
+ *
+ * @param label string to add to the table
+ * @return same string, now stored in the table
+ */
+const char *
+add_label (char *label)
+{
+ if (label_off == label_len)
+ GNUNET_array_grow (labels,
+ label_len,
+ label_len * 2 + 4);
+ labels[label_off++] = label;
+ return label;
+}
+
+
static struct TALER_TESTING_Command
-CMD_TRANSFER_TO_EXCHANGE (char *label, char *amount)
+cmd_transfer_to_exchange (const char *label,
+ const char *amount)
{
return TALER_TESTING_cmd_admin_add_incoming_retry
(TALER_TESTING_cmd_admin_add_incoming (label,
@@ -283,9 +317,8 @@ run (void *cls,
j);
{
struct TALER_TESTING_Command make_reserve[] = {
- CMD_TRANSFER_TO_EXCHANGE (create_reserve_label,
- TALER_amount_to_string
- (&total_reserve_amount)),
+ cmd_transfer_to_exchange (add_label (create_reserve_label),
+ TALER_amount2s (&total_reserve_amount)),
TALER_TESTING_cmd_end ()
};
char *batch_label;
@@ -294,7 +327,7 @@ run (void *cls,
"batch-start-%u",
j);
all_commands[j * (howmany_coins + 1)]
- = TALER_TESTING_cmd_batch (batch_label,
+ = TALER_TESTING_cmd_batch (add_label (batch_label),
make_reserve);
}
for (unsigned int i = 0; i < howmany_coins; i++)
@@ -313,17 +346,17 @@ run (void *cls,
i + (howmany_coins * j));
unit[0] =
TALER_TESTING_cmd_withdraw_with_retry
- (TALER_TESTING_cmd_withdraw_amount (withdraw_label,
+ (TALER_TESTING_cmd_withdraw_amount (add_label (withdraw_label),
create_reserve_label,
amount_5,
MHD_HTTP_OK));
unit[1] =
TALER_TESTING_cmd_deposit_with_retry
(TALER_TESTING_cmd_deposit ("deposit",
- withdraw_label,
+ add_label (withdraw_label),
0, /* Index of the one withdrawn coin in the traits. */
user_payto_uri,
- order_enc,
+ add_label (order_enc),
GNUNET_TIME_UNIT_ZERO,
amount_1,
MHD_HTTP_OK));
@@ -341,16 +374,16 @@ run (void *cls,
i,
j);
unit[2] =
- TALER_TESTING_cmd_refresh_melt_with_retry (
- TALER_TESTING_cmd_refresh_melt
- (melt_label,
+ TALER_TESTING_cmd_refresh_melt_with_retry
+ (TALER_TESTING_cmd_refresh_melt
+ (add_label (melt_label),
withdraw_label,
MHD_HTTP_OK,
NULL));
unit[3] =
TALER_TESTING_cmd_refresh_reveal_with_retry
(TALER_TESTING_cmd_refresh_reveal
- (reveal_label,
+ (add_label (reveal_label),
melt_label,
MHD_HTTP_OK));
unit[4] =
@@ -369,7 +402,7 @@ run (void *cls,
i,
j);
all_commands[j * (howmany_coins + 1) + (1 + i)]
- = TALER_TESTING_cmd_batch (unit_label,
+ = TALER_TESTING_cmd_batch (add_label (unit_label),
unit);
}
}
@@ -962,5 +995,10 @@ main (int argc,
(unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
+ usage.ru_utime.tv_usec));
}
+ for (unsigned int i = 0; i<label_off; i++)
+ GNUNET_free (labels[i]);
+ GNUNET_array_grow (labels,
+ label_len,
+ 0);
return (GNUNET_OK == result) ? 0 : result;
}
diff --git a/src/exchange/test_taler_exchange_httpd_afl.sh b/src/exchange/test_taler_exchange_httpd_afl.sh
index 48beda722..6d741acce 100644
--- a/src/exchange/test_taler_exchange_httpd_afl.sh
+++ b/src/exchange/test_taler_exchange_httpd_afl.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
# This file is part of TALER
-# Copyright (C) 2015 GNUnet e.V.
+# Copyright (C) 2015, 2020 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
@@ -21,21 +21,22 @@
#
# We read the JSON snippets from afl-tests/
#
+set -eu
+
PREFIX=
# Uncomment this line to run with valgrind...
-PREFIX="valgrind --leak-check=yes --log-file=valgrind.%p"
+# PREFIX="valgrind --leak-check=yes --log-file=valgrind.%p"
# Setup keys.
-taler-exchange-keyup -d test-exchange-home -m test-exchange-home/master.priv
+taler-exchange-keyup -c test_taler_exchange_httpd.conf
# Setup database (just to be sure)
-taler-exchange-dbinit -d test-exchange-home &> /dev/null || true
+taler-exchange-dbinit -c test_taler_exchange_httpd.conf &> /dev/null
# Only log hard errors, we expect lots of warnings...
export GNUNET_FORCE_LOG="taler-exchange-httpd;;;;ERROR/libmicrohttpd;;;;ERROR/util;;;;ERROR/"
# Run test...
for n in afl-tests/*
do
echo -n "Test $n "
- $PREFIX taler-exchange-httpd -d test-exchange-home/ -t 1 -f $n -C > /dev/null || { echo "FAIL!"; }
-# $PREFIX taler-exchange-httpd -d test-exchange-home/ -t 1 -f $n -C > /dev/null || { echo "FAIL!"; exit 1; }
+ $PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf -t 1 -f $n -C > /dev/null || { echo "FAIL!"; }
echo "OK"
done
exit 0
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 33e9681f1..783cddea2 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -2156,7 +2156,6 @@ TALER_EXCHANGE_destroy_denomination_key (struct
TALER_EXCHANGE_DenomPublicKey *key)
{
GNUNET_CRYPTO_rsa_public_key_free (key->key.rsa_public_key);;
- key->key.rsa_public_key = NULL;
GNUNET_free (key);
}
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index b62420557..207d11876 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -263,23 +263,23 @@ withdraw_run (void *cls,
}
TALER_planchet_setup_random (&ws->ps);
ws->is = is;
-
- dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
- &ws->amount);
- if (NULL == dpk)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to determine denomination key at %s\n",
- (NULL != cmd) ? cmd->label : "<retried command>");
- GNUNET_assert (0);
- }
- else
+ if (NULL == ws->pk)
{
+ dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
+ &ws->amount);
+ if (NULL == dpk)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to determine denomination key at %s\n",
+ (NULL != cmd) ? cmd->label : "<retried command>");
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
/* We copy the denomination key, as re-querying /keys
* would free the old one. */
ws->pk = TALER_EXCHANGE_copy_denomination_key (dpk);
}
-
ws->wsh = TALER_EXCHANGE_reserve_withdraw (is->exchange,
ws->pk,
rp,