From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 18 Nov 2026 17:41:26 +0100 Subject: [PATCH] util: bound and check failure replies from the denomination helpers A failure reply after the last expected one moved the write position past the batch, and a failure carrying TALER_EC_NONE passed for success with signatures missing. Issue: https://bugs.taler.net/n/12213 Assisted by LLM --- src/util/crypto_helper_cs.c | 26 ++++++++++++++++++++++++++ src/util/crypto_helper_rsa.c | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/util/crypto_helper_cs.c b/src/util/crypto_helper_cs.c index c7fb2a8f9..44efe90f5 100644 --- a/src/util/crypto_helper_cs.c +++ b/src/util/crypto_helper_cs.c @@ -615,11 +615,24 @@ more: do_disconnect (dh); return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; } + if (finished) + { + /* more replies than requests in this batch */ + GNUNET_break_op (0); + do_disconnect (dh); + return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } { const struct TALER_CRYPTO_SignFailure *sf = (const struct TALER_CRYPTO_SignFailure *) buf; ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec); + if (TALER_EC_NONE == ec) + { + /* a failure must not pass for success */ + GNUNET_break_op (0); + ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Signing %u failed with status %d!\n", wpos, @@ -864,11 +877,24 @@ more: do_disconnect (dh); return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; } + if (finished) + { + /* more replies than requests in this batch */ + GNUNET_break_op (0); + do_disconnect (dh); + return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } { const struct TALER_CRYPTO_RDeriveFailure *rdf = (const struct TALER_CRYPTO_RDeriveFailure *) buf; ec = (enum TALER_ErrorCode) (int) ntohl (rdf->ec); + if (TALER_EC_NONE == ec) + { + /* a failure must not pass for success */ + GNUNET_break_op (0); + ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "R derivation %u failed with status %d!\n", wpos, diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c index 1307dfc02..a6c0f845d 100644 --- a/src/util/crypto_helper_rsa.c +++ b/src/util/crypto_helper_rsa.c @@ -622,11 +622,24 @@ more: do_disconnect (dh); return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; } + if (finished) + { + /* more replies than requests in this batch */ + GNUNET_break_op (0); + do_disconnect (dh); + return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } { const struct TALER_CRYPTO_SignFailure *sf = (const struct TALER_CRYPTO_SignFailure *) buf; ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec); + if (TALER_EC_NONE == ec) + { + /* a failure must not pass for success */ + GNUNET_break_op (0); + ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Signing %u failed with status %d!\n", wpos, -- 2.47.3