summaryrefslogtreecommitdiff
path: root/src/util/amount.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-01 23:07:36 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-01 23:07:36 +0100
commit2d08d612f6802f9a369755267bf4a113cdc8d871 (patch)
tree4625e9f8811e29009bc45f79dcb0a2476bd50227 /src/util/amount.c
parent4f2ad1051b1433974e5d598b1546202797729e31 (diff)
downloadexchange-2d08d612f6802f9a369755267bf4a113cdc8d871.tar.gz
exchange-2d08d612f6802f9a369755267bf4a113cdc8d871.tar.bz2
exchange-2d08d612f6802f9a369755267bf4a113cdc8d871.zip
refuse endian conversion for invalid amounts
Diffstat (limited to 'src/util/amount.c')
-rw-r--r--src/util/amount.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/util/amount.c b/src/util/amount.c
index 7765c74bb..20d064243 100644
--- a/src/util/amount.c
+++ b/src/util/amount.c
@@ -207,6 +207,8 @@ void
TALER_amount_hton (struct TALER_AmountNBO *res,
const struct TALER_Amount *d)
{
+ GNUNET_assert (GNUNET_YES ==
+ TALER_amount_is_valid (d));
res->value = GNUNET_htonll (d->value);
res->fraction = htonl (d->fraction);
memcpy (res->currency,
@@ -230,6 +232,8 @@ TALER_amount_ntoh (struct TALER_Amount *res,
memcpy (res->currency,
dn->currency,
TALER_CURRENCY_LEN);
+ GNUNET_assert (GNUNET_YES ==
+ TALER_amount_is_valid (res));
}