summaryrefslogtreecommitdiff
path: root/src/util/amount.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-05-10 09:13:09 +0200
committerChristian Grothoff <christian@grothoff.org>2023-05-10 09:13:09 +0200
commit495496340554ec4699e9dbc561d921b242c92e6d (patch)
tree2a5d4ca224aa804495e7ae23ebff316ea6df0176 /src/util/amount.c
parent5259ea05321783a177cab9e30f77cb3dc6f54049 (diff)
downloadexchange-495496340554ec4699e9dbc561d921b242c92e6d.tar.gz
exchange-495496340554ec4699e9dbc561d921b242c92e6d.tar.bz2
exchange-495496340554ec4699e9dbc561d921b242c92e6d.zip
ensure amounts are in upper-case
Diffstat (limited to 'src/util/amount.c')
-rw-r--r--src/util/amount.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/util/amount.c b/src/util/amount.c
index dfe10b07e..9cd0739c9 100644
--- a/src/util/amount.c
+++ b/src/util/amount.c
@@ -72,9 +72,8 @@ TALER_string_to_amount (const char *str,
}
GNUNET_assert (TALER_CURRENCY_LEN > (colon - str));
- GNUNET_memcpy (amount->currency,
- str,
- colon - str);
+ for (unsigned int i = 0; i<colon - str; i++)
+ amount->currency[i] = toupper (str[i]);
/* 0-terminate *and* normalize buffer by setting everything to '\0' */
memset (&amount->currency [colon - str],
0,
@@ -193,9 +192,8 @@ TALER_amount_hton (struct TALER_AmountNBO *res,
TALER_amount_is_valid (d));
res->value = GNUNET_htonll (d->value);
res->fraction = htonl (d->fraction);
- GNUNET_memcpy (res->currency,
- d->currency,
- TALER_CURRENCY_LEN);
+ for (unsigned int i = 0; i<TALER_CURRENCY_LEN; i++)
+ res->currency[i] = toupper (d->currency[i]);
}
@@ -225,9 +223,8 @@ TALER_amount_set_zero (const char *cur,
memset (amount,
0,
sizeof (struct TALER_Amount));
- GNUNET_memcpy (amount->currency,
- cur,
- slen);
+ for (unsigned int i = 0; i<slen; i++)
+ amount->currency[i] = toupper (cur[i]);
return GNUNET_OK;
}