aboutsummaryrefslogtreecommitdiff
path: root/src/auditor
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-09-14 15:29:18 +0200
committerChristian Grothoff <christian@grothoff.org>2024-09-14 15:29:18 +0200
commit5a3d432138f722c46a2b1d6b7f1e220e9005dde7 (patch)
tree69a9877fa1465f30c88e85447639fec7dccedc08 /src/auditor
parent17b6f7fb7f03facbdc23be6a7f815cecd8aa3536 (diff)
fix various ugly auditor logic bugs, including crash bugs, uninitialized memory, and memory leaks
Diffstat (limited to 'src/auditor')
-rw-r--r--src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c75
-rw-r--r--src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c71
-rw-r--r--src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c64
3 files changed, 103 insertions, 107 deletions
diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c
index 514422e5d..3a2b6def3 100644
--- a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c
@@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -26,14 +24,15 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_reserve-in-inconsistency-get.h"
+
/**
-* Add reserve-in-inconsistency to the list.
-*
-* @param[in,out] cls a `json_t *` array to extend
-* @param serial_id location of the @a dc in the database
-* @param dc struct of inconsistencies
-* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
-*/
+ * Add reserve-in-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param serial_id location of the @a dc in the database
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_reserve_in_inconsistency (
void *cls,
@@ -44,18 +43,24 @@ process_reserve_in_inconsistency (
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_int64 ("row_id", serial_id),
+ GNUNET_JSON_pack_uint64 ("row_id",
+ serial_id),
+ GNUNET_JSON_pack_uint64 ("bank_row_id",
+ dc->bank_row_id),
TALER_JSON_pack_amount ("amount_exchange_expected",
&dc->amount_exchange_expected),
- TALER_JSON_pack_amount ("amount_wired", &dc->amount_wired),
- GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
- TALER_JSON_pack_time_abs_human ("timestamp", dc->timestamp),
- GNUNET_JSON_pack_string ("account", dc->account),
- GNUNET_JSON_pack_string ("diagnostic", dc->diagnostic),
- GNUNET_JSON_pack_bool ("suppressed", dc->suppressed)
-
-
+ TALER_JSON_pack_amount ("amount_wired",
+ &dc->amount_wired),
+ GNUNET_JSON_pack_data_auto ("reserve_pub",
+ &dc->reserve_pub),
+ TALER_JSON_pack_time_abs_human ("timestamp",
+ dc->timestamp),
+ GNUNET_JSON_pack_string ("account",
+ dc->account),
+ GNUNET_JSON_pack_string ("diagnostic",
+ dc->diagnostic),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
@@ -77,6 +82,9 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -91,34 +99,30 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if ( (NULL != ret_s) &&
+ (0 == strcmp (ret_s,
+ "true")) )
+ {
+ return_suppressed = true;
+ }
}
-
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_reserve_in_inconsistency (
TAH_plugin->cls,
limit,
@@ -126,7 +130,6 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get (
return_suppressed,
&process_reserve_in_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c
index 807e6dc55..4d8bbad3f 100644
--- a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c
@@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -26,39 +24,39 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h"
+
/**
-* Add reserve-not-closed-inconsistency to the list.
-*
-* @param[in,out] cls a `json_t *` array to extend
-* @param serial_id location of the @a dc in the database
-* @param dc struct of inconsistencies
-* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
-*/
+ * Add reserve-not-closed-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_reserve_not_closed_inconsistency (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_int64 ("row_id", serial_id),
- GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub),
- TALER_JSON_pack_amount ("balance", &dc->balance),
- TALER_JSON_pack_time_abs_human ("expiration_time", dc->expiration_time),
- GNUNET_JSON_pack_data_auto ("diagnostic", &dc->diagnostic),
- GNUNET_JSON_pack_bool ("suppressed", dc->suppressed)
-
-
+ GNUNET_JSON_pack_int64 ("row_id",
+ dc->row_id),
+ GNUNET_JSON_pack_data_auto ("reserve_pub",
+ &dc->reserve_pub),
+ TALER_JSON_pack_amount ("balance",
+ &dc->balance),
+ TALER_JSON_pack_time_abs_human ("expiration_time",
+ dc->expiration_time),
+ GNUNET_JSON_pack_data_auto ("diagnostic",
+ &dc->diagnostic),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
obj));
-
-
return GNUNET_OK;
}
@@ -74,6 +72,9 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -88,34 +89,31 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s
+ = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if ( (NULL != ret_s) &&
+ (0 == strcmp (ret_s,
+ "true")) )
+ {
+ return_suppressed = true;
+ }
}
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_reserve_not_closed_inconsistency (
TAH_plugin->cls,
limit,
@@ -123,7 +121,6 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get (
return_suppressed,
&process_reserve_not_closed_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
index 1c0b911a2..e529ce593 100644
--- a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
+++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c
@@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
-
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
@@ -26,32 +24,33 @@
#include "taler-auditor-httpd.h"
#include "taler-auditor-httpd_wire-format-inconsistency-get.h"
+
/**
-* Add wire-format-inconsistency to the list.
-*
-* @param[in,out] cls a `json_t *` array to extend
-* @param serial_id location of the @a dc in the database
-* @param dc struct of inconsistencies
-* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
-*/
+ * Add wire-format-inconsistency to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
static enum GNUNET_GenericReturnValue
process_wire_format_inconsistency (
void *cls,
- uint64_t serial_id,
const struct TALER_AUDITORDB_WireFormatInconsistency *dc)
{
json_t *list = cls;
json_t *obj;
obj = GNUNET_JSON_PACK (
-
- GNUNET_JSON_pack_int64 ("row_id", serial_id),
- TALER_JSON_pack_amount ("amount", &dc->amount),
- GNUNET_JSON_pack_int64 ("wire_offset", dc->wire_offset),
- GNUNET_JSON_pack_data_auto ("diagnostic", dc->diagnostic),
- GNUNET_JSON_pack_bool ("suppressed", dc->suppressed)
-
-
+ GNUNET_JSON_pack_uint64 ("row_id",
+ dc->row_id),
+ TALER_JSON_pack_amount ("amount",
+ &dc->amount),
+ GNUNET_JSON_pack_uint64 ("wire_offset",
+ dc->wire_offset),
+ GNUNET_JSON_pack_string ("diagnostic",
+ dc->diagnostic),
+ GNUNET_JSON_pack_bool ("suppressed",
+ dc->suppressed)
);
GNUNET_break (0 ==
json_array_append_new (list,
@@ -73,6 +72,9 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
(void) rh;
(void) connection_cls;
@@ -87,34 +89,29 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (
TALER_EC_GENERIC_DB_SETUP_FAILED,
NULL);
}
- ja = json_array ();
- GNUNET_break (NULL != ja);
-
- int64_t limit = -20;
- uint64_t offset;
-
TALER_MHD_parse_request_snumber (connection,
"limit",
&limit);
-
if (limit < 0)
offset = INT64_MAX;
else
offset = 0;
-
TALER_MHD_parse_request_number (connection,
"offset",
&offset);
-
- bool return_suppressed = false;
- const char *ret_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "return_suppressed");
- if (ret_s != NULL && strcmp (ret_s, "true") == 0)
{
- return_suppressed = true;
+ const char *ret_s = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if ( (NULL != ret_s) &&
+ (0 == strcmp (ret_s, "true")) )
+ {
+ return_suppressed = true;
+ }
}
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
qs = TAH_plugin->get_wire_format_inconsistency (
TAH_plugin->cls,
limit,
@@ -122,7 +119,6 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (
return_suppressed,
&process_wire_format_inconsistency,
ja);
-
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);