From 5587732f5276621ada83a53d1fb0ee8b6f80032b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 00:41:19 +0100 Subject: fix auditor to properly verify wire fee signatures and more gracefully handle arithmetic amount issue --- src/auditor/taler-auditor.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/auditor') diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 870a81a42..89f044608 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -1664,10 +1664,15 @@ struct WireFeeInfo struct GNUNET_TIME_Absolute end_date; /** - * How high is the fee. + * How high is the wire fee. */ struct TALER_Amount wire_fee; + /** + * How high is the closing fee. + */ + struct TALER_Amount closing_fee; + }; @@ -1815,6 +1820,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount spent; struct TALER_Amount value; struct TALER_Amount merchant_loss; + struct TALER_Amount merchant_delta; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking transaction history of coin %s\n", @@ -2043,7 +2049,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, /* Finally, update @a merchant_gain by subtracting what he "lost" from refunds */ if (GNUNET_SYSERR == - TALER_amount_subtract (merchant_gain, + TALER_amount_subtract (&merchant_delta, merchant_gain, &merchant_loss)) { @@ -2055,6 +2061,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, 0); return GNUNET_SYSERR; } + *merchant_gain = merchant_delta; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Coin %s contributes %s to contract %s\n", TALER_B2S (coin_pub), @@ -2276,6 +2283,7 @@ get_wire_fee (struct AggregationContext *ac, &wfi->start_date, &wfi->end_date, &wfi->wire_fee, + &wfi->closing_fee, &master_sig)) { GNUNET_break (0); @@ -2299,6 +2307,8 @@ get_wire_fee (struct AggregationContext *ac, wp.end_date = GNUNET_TIME_absolute_hton (wfi->end_date); TALER_amount_hton (&wp.wire_fee, &wfi->wire_fee); + TALER_amount_hton (&wp.closing_fee, + &wfi->closing_fee); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES, &wp.purpose, -- cgit v1.2.3