commit cafe3b2c93136904859a5ccbd54c1249beba0983
parent 0ade5f71d24f9290d056d0924527fdae45a853c7
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 6 Aug 2026 00:11:36 +0200
fix test and initialize out values in case we get no return values
Diffstat:
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/backenddb/insert_issued_token.c b/src/backenddb/insert_issued_token.c
@@ -38,8 +38,8 @@ TALER_MERCHANTDB_insert_issued_token (
GNUNET_PQ_query_param_blinded_sig (blind_sig->signature),
GNUNET_PQ_query_param_end
};
- bool no_fam;
- bool existed;
+ bool no_fam = false;
+ bool existed = false;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("out_no_family",
&no_fam),
@@ -62,7 +62,7 @@ TALER_MERCHANTDB_insert_issued_token (
params,
rs);
*no_family = false;
- if (qs < 0)
+ if (qs <= 0)
return qs;
if (no_fam)
{
diff --git a/src/backenddb/insert_used_token.c b/src/backenddb/insert_used_token.c
@@ -42,8 +42,8 @@ TALER_MERCHANTDB_insert_used_token (
GNUNET_PQ_query_param_unblinded_sig (issue_sig->signature),
GNUNET_PQ_query_param_end
};
- bool no_fam;
- bool conflict; /* used to signal double-spending */
+ bool no_fam = false;
+ bool conflict = false; /* used to signal double-spending */
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("out_no_family",
&no_fam),
@@ -69,7 +69,7 @@ TALER_MERCHANTDB_insert_used_token (
params,
rs);
*no_family = false;
- if (qs < 0)
+ if (qs <= 0)
return qs;
if (no_fam)
{
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
@@ -2717,7 +2717,11 @@ test_insert_issued_token (const struct TestTokens_Closure *cls,
enum GNUNET_DB_QueryStatus expected_result,
bool expect_no_family)
{
- bool no_family;
+ /* Deliberately poisoned: the DB layer must assign the flag on every
+ path, including the ones where it returns early. Note that the
+ 'qs <= 0' early return itself is not reachable from here: a stored
+ procedure with OUT parameters always yields exactly one row. */
+ bool no_family = true;
TEST_SET_INSTANCE (cls->instance.instance.id,
expected_result);
@@ -2755,7 +2759,8 @@ test_insert_used_token (const struct TestTokens_Closure *cls,
enum GNUNET_DB_QueryStatus expected_result,
bool expect_no_family)
{
- bool no_family;
+ /* Deliberately poisoned: see test_insert_issued_token(). */
+ bool no_family = true;
TEST_SET_INSTANCE (cls->instance.instance.id,
expected_result);