diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2024-10-23 01:17:45 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2024-10-23 01:17:45 +0200 |
commit | 69d4d7c860e1175f785d0b583525241389df4866 (patch) | |
tree | 821c8dea57bdcf3614c293e667c3953f431b498f /src | |
parent | 1f6f7397df543cec5703ace30f5bb26e14b999e3 (diff) |
fix mis-use of API for conversion of timestamp to seconds
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders.c | 2 | ||||
-rw-r--r-- | src/lib/merchant_api_get_orders.c | 8 | ||||
-rw-r--r-- | src/lib/merchant_api_get_transfers.c | 18 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 13afee0a..47c27419 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -754,7 +754,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, - "date_ms"); + "date_s"); } po->of.date = GNUNET_TIME_absolute_to_timestamp ( diff --git a/src/lib/merchant_api_get_orders.c b/src/lib/merchant_api_get_orders.c index 459409fd..87e4a2c4 100644 --- a/src/lib/merchant_api_get_orders.c +++ b/src/lib/merchant_api_get_orders.c @@ -306,7 +306,7 @@ TALER_MERCHANT_orders_get3 ( /* build ogh->url with the various optional arguments */ { - char *dstr; + char dstr[30]; char *fec = NULL; char *sid = NULL; bool have_date; @@ -335,7 +335,10 @@ TALER_MERCHANT_orders_get3 ( (void) GNUNET_STRINGS_urlencode (strlen (fulfillment_url), fulfillment_url, &fec); - dstr = GNUNET_strdup (GNUNET_TIME_timestamp2s (date)); + GNUNET_snprintf (dstr, + sizeof (dstr), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (date)); if (delta > 0) { have_date = ! GNUNET_TIME_absolute_is_zero (date.abs_time); @@ -381,7 +384,6 @@ TALER_MERCHANT_orders_get3 ( "fulfillment_url", fec, NULL); - GNUNET_free (dstr); GNUNET_free (sid); GNUNET_free (fec); } diff --git a/src/lib/merchant_api_get_transfers.c b/src/lib/merchant_api_get_transfers.c index 6116a54f..2995be11 100644 --- a/src/lib/merchant_api_get_transfers.c +++ b/src/lib/merchant_api_get_transfers.c @@ -233,8 +233,8 @@ TALER_MERCHANT_transfers_get ( const char *verified_s = NULL; char limit_s[30]; char offset_s[30]; - char *before_s; - char *after_s; + char before_s[30]; + char after_s[30]; gth = GNUNET_new (struct TALER_MERCHANT_GetTransfersHandle); gth->ctx = ctx; @@ -249,8 +249,16 @@ TALER_MERCHANT_transfers_get ( sizeof (offset_s), "%lld", (unsigned long long) offset); - before_s = GNUNET_strdup (GNUNET_TIME_timestamp2s (before)); - after_s = GNUNET_strdup (GNUNET_TIME_timestamp2s (after)); + + + GNUNET_snprintf (before_s, + sizeof (before_s), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (before)); + GNUNET_snprintf (after_s, + sizeof (after_s), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (after)); gth->url = TALER_url_join (backend_url, "private/transfers", "payto_uri", @@ -276,8 +284,6 @@ TALER_MERCHANT_transfers_get ( ? NULL : after_s, NULL); - GNUNET_free (before_s); - GNUNET_free (after_s); if (NULL == gth->url) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |