refuse endian conversion for invalid amounts

This commit is contained in:
Christian Grothoff 2018-01-01 23:07:36 +01:00
parent 4f2ad1051b
commit 2d08d612f6
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -207,6 +207,8 @@ void
TALER_amount_hton (struct TALER_AmountNBO *res, TALER_amount_hton (struct TALER_AmountNBO *res,
const struct TALER_Amount *d) const struct TALER_Amount *d)
{ {
GNUNET_assert (GNUNET_YES ==
TALER_amount_is_valid (d));
res->value = GNUNET_htonll (d->value); res->value = GNUNET_htonll (d->value);
res->fraction = htonl (d->fraction); res->fraction = htonl (d->fraction);
memcpy (res->currency, memcpy (res->currency,
@ -230,6 +232,8 @@ TALER_amount_ntoh (struct TALER_Amount *res,
memcpy (res->currency, memcpy (res->currency,
dn->currency, dn->currency,
TALER_CURRENCY_LEN); TALER_CURRENCY_LEN);
GNUNET_assert (GNUNET_YES ==
TALER_amount_is_valid (res));
} }