exchange

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

commit 10d9aa40ccd25d45a0779cf7625dc8fa0e634176
parent 4f88960c502baa8f13064845bf66394429f35afb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 13 Aug 2026 20:03:35 +0200

batch size sanity bounds

Diffstat:
Msrc/util/crypto_helper_rsa.c | 18++++++++++++++++++
Msrc/util/secmod_rsa.c | 5++++-
2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c @@ -422,6 +422,22 @@ TALER_CRYPTO_helper_rsa_batch_sign ( memset (bss, 0, sizeof (*bss) * rsrs_length); + /* Every request must fit into an IPC message of its own, together + with the batch header; otherwise it could never be transmitted. */ + for (unsigned int i = 0; i<rsrs_length; i++) + { + if (rsrs[i].msg_size >= + UINT16_MAX + - sizeof (struct TALER_CRYPTO_BatchSignRequest) + - sizeof (struct TALER_CRYPTO_SignRequest)) + { + GNUNET_break_op (0); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Message to sign is too large (%llu bytes)\n", + (unsigned long long) rsrs[i].msg_size); + return TALER_EC_GENERIC_PARAMETER_MALFORMED; + } + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting signature process\n"); if (GNUNET_OK != @@ -441,6 +457,8 @@ TALER_CRYPTO_helper_rsa_batch_sign ( { unsigned int mlen = sizeof (struct TALER_CRYPTO_BatchSignRequest); + /* as each individual request fits, this loop always advances rend + at least once, and thus the outer loop makes progress */ while ( (rend < rsrs_length) && (mlen + sizeof (struct TALER_CRYPTO_SignRequest) diff --git a/src/util/secmod_rsa.c b/src/util/secmod_rsa.c @@ -769,7 +769,10 @@ handle_batch_sign_request (struct TES_Client *client, unsigned int idx = 0; bool failure = false; - if (bs > TALER_MAX_COINS) + /* an empty batch would be answered with no message at all, + leaving the client waiting for a reply forever */ + if ( (0 == bs) || + (bs > TALER_MAX_COINS) ) { GNUNET_break_op (0); return GNUNET_SYSERR;