exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit af6f2bb11e6ff60202d10e7623b3c66ef0882550
parent 0beffaf7054110952d5d386500f5c69749e2c6ae
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 13 Aug 2026 18:45:26 +0200

fix out-of-bounds read UB

Diffstat:
Msrc/exchangedb/helper.h | 9+++++----
Msrc/exchangedb/preflight.c | 6++++++
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/exchangedb/helper.h b/src/exchangedb/helper.h @@ -144,10 +144,11 @@ TALER_EXCHANGEDB_abs_limit (int64_t limit) } preps_[2]; /* 2 ctrs for taler-auditor-sync*/ \ unsigned int off_ = 0; \ \ - while ( (NULL != preps_[off_].pg) && \ - (pg != preps_[off_].pg) && \ - (off_ < sizeof(preps_) / sizeof(*preps_)) ) \ - off_++; \ + while ( (off_ < sizeof(preps_) / sizeof(*preps_)) && \ + (NULL != preps_[off_].pg) && \ + (pg != preps_[off_].pg) ) { \ + off_++; \ + } \ GNUNET_assert (off_ < \ sizeof(preps_) / sizeof(*preps_)); \ if (preps_[off_].cnt < TEH_PG_prep_gen_) \ diff --git a/src/exchangedb/preflight.c b/src/exchangedb/preflight.c @@ -49,6 +49,12 @@ TALER_EXCHANGEDB_preflight (struct TALER_EXCHANGEDB_PostgresContext *pg) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BUG: Preflight check failed to rollback transaction `%s'!\n", pg->transaction_name); + pg->transaction_name = NULL; + /* FIXME: modify GNUNET_PQ_reconnect_if_down () to tell + us if it did reconnect; if it did, GNUNET_NO is fine, + otherwise we probably want to return GNUNET_SYSERR here... */ + GNUNET_PQ_reconnect_if_down (pg->conn); + return GNUNET_NO; } pg->transaction_name = NULL; return GNUNET_NO;