exchange

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

commit 81a90052b068dfbbe25cf4a0c8c60ca7bd274628
parent 4a72063112931a95520b81e157209bdf82b7e95d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 12 Oct 2026 23:59:25 +0200

prevent log(neg) on exchange returning strange values

Diffstat:
Msrc/lib/exchange_api_stefan.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/lib/exchange_api_stefan.c b/src/lib/exchange_api_stefan.c @@ -149,9 +149,23 @@ TALER_EXCHANGE_keys_stefan_b2n ( return GNUNET_SYSERR; } min_d = amount_to_double (min); + if (min_d <= 0.0) + { + /* smallest denomination must have a positive value, + otherwise the logarithm below is undefined */ + GNUNET_break_op (0); + return GNUNET_SYSERR; + } fee_d = abs_d + log_d * log2 (bru_d / min_d) + lin_d * bru_d; + if (fee_d < 0.0) + { + /* log2() is negative for gross amounts below the smallest + denomination; a fee is never negative, and without this + clamp the net amount would exceed the gross amount */ + fee_d = 0.0; + } if (fee_d > bru_d) { GNUNET_assert (GNUNET_OK ==