exchange

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

commit 52e5368797adc1971cbd9050bbf3c3d0387c0846
parent f3c837a22aeb506344d1a7e928a32b3122a31c01
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 11 Oct 2026 14:34:31 +0200

handle external rater untrusted input without UB on NaN

Diffstat:
Msrc/exchange/taler-exchange-sanctionscheck.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/exchange/taler-exchange-sanctionscheck.c b/src/exchange/taler-exchange-sanctionscheck.c @@ -280,6 +280,12 @@ double_to_billion (double d) GNUNET_break (d >= 0); GNUNET_break (d <= 1.0); + /* The value comes from the external rater, so clamp it: casting a + negative (or huge) double to uint64_t is undefined behaviour. */ + if (! (d >= 0) ) /* also catches NaN */ + return 0; + if (d >= 1.0) + return 1000000000; r = round (d * 1000000000); return (uint64_t) r; }