commit 3c98cb4d8ba96936859ba7ee1cf301966210b824
parent d558df9ea5f6ebd31ca566529b9f218ab7202d30
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sat, 18 Jul 2026 00:09:35 +0200
fix usage of year
Diffstat:
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/donau/donau-httpd_post-batch-issue-CHARITY_ID.c b/src/donau/donau-httpd_post-batch-issue-CHARITY_ID.c
@@ -118,8 +118,9 @@ DH_handler_post_batch_issue (struct DH_RequestContext *rc,
const json_t *root,
const char *const args[1])
{
+ unsigned int current_year = GNUNET_TIME_get_current_year ();
struct DONAU_CharitySignatureP charity_sig;
- uint64_t year;
+ uint32_t year;
bool second_time = false;
unsigned long long charity_id;
char dummy;
@@ -153,7 +154,7 @@ DH_handler_post_batch_issue (struct DH_RequestContext *rc,
&budikeypairs),
GNUNET_JSON_spec_fixed_auto ("charity_sig",
&charity_sig),
- GNUNET_JSON_spec_uint64 ("year",
+ GNUNET_JSON_spec_uint32 ("year",
&year),
GNUNET_JSON_spec_end ()
};
@@ -319,9 +320,13 @@ DH_handler_post_batch_issue (struct DH_RequestContext *rc,
GNUNET_CRYPTO_hash_context_read (hc,
&charity_sig,
sizeof (struct DONAU_CharitySignatureP));
- GNUNET_CRYPTO_hash_context_read (hc,
- &year,
- sizeof (uint64_t));
+ {
+ uint32_t year_be = htonl (year);
+
+ GNUNET_CRYPTO_hash_context_read (hc,
+ &year_be,
+ sizeof (uint32_t));
+ }
GNUNET_CRYPTO_hash_context_finish (hc,
&h_receipts.hash);
@@ -408,8 +413,7 @@ start:
TALER_EC_DONAU_GENERIC_DONATION_UNIT_WRONG_YEAR,
year_str);
}
- year = GNUNET_TIME_get_current_year ();
- if (dk->validity_year < year)
+ if (dk->validity_year < current_year)
{
char year_str[20];
@@ -426,7 +430,7 @@ start:
TALER_EC_DONAU_GENERIC_DONATION_UNIT_EXPIRED,
year_str);
}
- if (dk->validity_year > year)
+ if (dk->validity_year > current_year)
{
char year_str[20];
@@ -483,7 +487,7 @@ start:
/* save new receipts to date and save receipts Request (blinded signatures,
* charity id, amount, hash over bkps) to make it idempotent*/
qs_insert_ir = DONAUDB_insert_issued_receipt (DH_context,
- (uint32_t) year,
+ year,
num_bkps,
du_sigs,
(uint64_t) charity_id,
diff --git a/src/donaudb/lookup_issued_receipts.c b/src/donaudb/lookup_issued_receipts.c
@@ -26,6 +26,7 @@
#include "helper.h"
#include "donau_pq_lib.h"
+
enum GNUNET_DB_QueryStatus
DONAUDB_lookup_issued_receipts (struct DONAUDB_PostgresContext *ctx,
struct DONAU_DonationReceiptHashP *h_receipts,