aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_confirmation.c5
-rw-r--r--src/util/crypto_contract.c11
-rw-r--r--src/util/crypto_helper_common.c1
-rw-r--r--src/util/crypto_helper_cs.c8
-rw-r--r--src/util/crypto_helper_esign.c2
-rw-r--r--src/util/crypto_helper_rsa.c6
-rw-r--r--src/util/iban.c4
-rw-r--r--src/util/os_installation.c3
-rw-r--r--src/util/payto.c2
-rw-r--r--src/util/secmod_common.c39
-rw-r--r--src/util/taler-exchange-secmod-cs.c40
-rw-r--r--src/util/taler-exchange-secmod-eddsa.c18
-rw-r--r--src/util/taler-exchange-secmod-rsa.c43
-rw-r--r--src/util/tokens.c2
14 files changed, 91 insertions, 93 deletions
diff --git a/src/util/crypto_confirmation.c b/src/util/crypto_confirmation.c
index 99552f150..ee043404f 100644
--- a/src/util/crypto_confirmation.c
+++ b/src/util/crypto_confirmation.c
@@ -29,7 +29,7 @@
* How long is a TOTP code valid?
*/
#define TOTP_VALIDITY_PERIOD GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS, 30)
+ GNUNET_TIME_UNIT_SECONDS, 30)
/**
* Range of time we allow (plus-minus).
@@ -132,6 +132,7 @@ TALER_rfc3548_base32decode (const char *val,
{
if ((rpos < val_size) && (vbit < 8))
{
+ const char *p;
char c = val[rpos++];
if (c == '=')
@@ -144,7 +145,7 @@ TALER_rfc3548_base32decode (const char *val,
break; /* Ok, 2x '=' padding is allowed */
return -1; /* invalid padding */
}
- const char *p = strchr (decTable__, toupper (c));
+ p = strchr (decTable__, toupper (c));
if (! p)
{
/* invalid character */
diff --git a/src/util/crypto_contract.c b/src/util/crypto_contract.c
index bec34c983..8656af766 100644
--- a/src/util/crypto_contract.c
+++ b/src/util/crypto_contract.c
@@ -459,12 +459,6 @@ TALER_CRYPTO_contract_decrypt_for_deposit (
size_t econtract_size)
{
const struct TALER_PurseContractPublicKeyP *purse_pub = econtract;
-
- if (econtract_size < sizeof (*purse_pub))
- {
- GNUNET_break_op (0);
- return NULL;
- }
struct GNUNET_HashCode key;
void *xhdr;
size_t hdr_size;
@@ -474,6 +468,11 @@ TALER_CRYPTO_contract_decrypt_for_deposit (
json_error_t json_error;
json_t *ret;
+ if (econtract_size < sizeof (*purse_pub))
+ {
+ GNUNET_break_op (0);
+ return NULL;
+ }
if (GNUNET_OK !=
GNUNET_CRYPTO_ecdh_eddsa (&contract_priv->ecdhe_priv,
&purse_pub->eddsa_pub,
diff --git a/src/util/crypto_helper_common.c b/src/util/crypto_helper_common.c
index 9eddb7dcb..d39b61933 100644
--- a/src/util/crypto_helper_common.c
+++ b/src/util/crypto_helper_common.c
@@ -21,6 +21,7 @@
#include "platform.h"
#include "taler_util.h"
#include "taler_signatures.h"
+#include "crypto_helper_common.h"
enum GNUNET_GenericReturnValue
diff --git a/src/util/crypto_helper_cs.c b/src/util/crypto_helper_cs.c
index 4c4a56feb..d423ae640 100644
--- a/src/util/crypto_helper_cs.c
+++ b/src/util/crypto_helper_cs.c
@@ -534,7 +534,7 @@ more:
const struct TALER_CRYPTO_SignFailure *sf =
(const struct TALER_CRYPTO_SignFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (sf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Signing failed with status %d!\n",
ec);
@@ -757,7 +757,7 @@ more:
const struct TALER_CRYPTO_RDeriveFailure *rdf =
(const struct TALER_CRYPTO_RDeriveFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (rdf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (rdf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"R derivation failed!\n");
finished = true;
@@ -995,7 +995,7 @@ more:
const struct TALER_CRYPTO_SignFailure *sf =
(const struct TALER_CRYPTO_SignFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (sf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Signing %u failed with status %d!\n",
wpos,
@@ -1238,7 +1238,7 @@ more:
const struct TALER_CRYPTO_RDeriveFailure *rdf =
(const struct TALER_CRYPTO_RDeriveFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (rdf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (rdf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"R derivation %u failed with status %d!\n",
wpos,
diff --git a/src/util/crypto_helper_esign.c b/src/util/crypto_helper_esign.c
index e044d31d1..4c46cec56 100644
--- a/src/util/crypto_helper_esign.c
+++ b/src/util/crypto_helper_esign.c
@@ -466,7 +466,7 @@ more:
(const struct TALER_CRYPTO_EddsaSignFailure *) buf;
finished = true;
- ec = (enum TALER_ErrorCode) ntohl (sf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
break;
}
case TALER_HELPER_EDDSA_MT_AVAIL:
diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c
index e23e12a88..df14c9100 100644
--- a/src/util/crypto_helper_rsa.c
+++ b/src/util/crypto_helper_rsa.c
@@ -21,9 +21,9 @@
#include "platform.h"
#include "taler_util.h"
#include "taler_signatures.h"
+#include "crypto_helper_common.h"
#include "taler-exchange-secmod-rsa.h"
#include <poll.h>
-#include "crypto_helper_common.h"
struct TALER_CRYPTO_RsaDenominationHelper
@@ -553,7 +553,7 @@ more:
const struct TALER_CRYPTO_SignFailure *sf =
(const struct TALER_CRYPTO_SignFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (sf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Signing failed!\n");
finished = true;
@@ -808,7 +808,7 @@ more:
const struct TALER_CRYPTO_SignFailure *sf =
(const struct TALER_CRYPTO_SignFailure *) buf;
- ec = (enum TALER_ErrorCode) ntohl (sf->ec);
+ ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Signing %u failed with status %d!\n",
wpos,
diff --git a/src/util/iban.c b/src/util/iban.c
index c2274d3cb..8d1e898cb 100644
--- a/src/util/iban.c
+++ b/src/util/iban.c
@@ -223,7 +223,6 @@ TALER_iban_validate (const char *iban)
char *nbuf;
unsigned long long dividend;
unsigned long long remainder;
- unsigned int i;
unsigned int j;
if (NULL == iban)
@@ -255,7 +254,8 @@ TALER_iban_validate (const char *iban)
return msg;
}
nbuf = GNUNET_malloc ((len * 2) + 1);
- for (i = 0, j = 0; i < len; i++)
+ j = 0;
+ for (unsigned int i = 0; i < len; i++)
{
if (isalpha ((unsigned char) ibancpy[i]))
{
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 1cbb9e78a..79beba51c 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -24,7 +24,7 @@
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
-
+#include "taler_util.h"
/**
* Default project data used for installation path detection
@@ -44,6 +44,7 @@ static const struct GNUNET_OS_ProjectData taler_pd = {
.is_gnu = 1,
.gettext_domain = "taler",
.gettext_path = NULL,
+ .agpl_url = "https://git.taler.net/"
};
diff --git a/src/util/payto.c b/src/util/payto.c
index a471175a9..528108efa 100644
--- a/src/util/payto.c
+++ b/src/util/payto.c
@@ -347,8 +347,6 @@ TALER_payto_validate (const char *payto_uri)
if (NULL == strchr (ALLOWED_CHARACTERS,
(int) payto_uri[i]))
{
- char *ret;
-
GNUNET_asprintf (&ret,
"Encountered invalid character `%c' at offset %u in payto URI `%s'",
payto_uri[i],
diff --git a/src/util/secmod_common.c b/src/util/secmod_common.c
index 87ce17e06..3156b15c4 100644
--- a/src/util/secmod_common.c
+++ b/src/util/secmod_common.c
@@ -133,7 +133,7 @@ TES_transmit (int sock,
struct GNUNET_NETWORK_Handle *
-TES_open_socket (const char *unixpath)
+TES_open_socket (const char *my_unixpath)
{
int sock;
mode_t old_umask;
@@ -159,25 +159,25 @@ TES_open_socket (const char *unixpath)
struct sockaddr_un un;
if (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (unixpath))
+ GNUNET_DISK_directory_create_for_file (my_unixpath))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
"mkdir(dirname)",
- unixpath);
+ my_unixpath);
}
- if (0 != unlink (unixpath))
+ if (0 != unlink (my_unixpath))
{
if (ENOENT != errno)
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
"unlink",
- unixpath);
+ my_unixpath);
}
memset (&un,
0,
sizeof (un));
un.sun_family = AF_UNIX;
strncpy (un.sun_path,
- unixpath,
+ my_unixpath,
sizeof (un.sun_path) - 1);
if (0 != bind (sock,
(const struct sockaddr *) &un,
@@ -185,7 +185,7 @@ TES_open_socket (const char *unixpath)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"bind",
- unixpath);
+ my_unixpath);
GNUNET_break (0 == close (sock));
goto cleanup;
}
@@ -196,7 +196,7 @@ TES_open_socket (const char *unixpath)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"listen",
- unixpath);
+ my_unixpath);
GNUNET_break (GNUNET_OK ==
GNUNET_NETWORK_socket_close (ret));
ret = NULL;
@@ -218,14 +218,17 @@ TES_wake_clients (void)
NULL != client;
client = client->next)
{
- GNUNET_assert (sizeof (num) ==
#ifdef __linux__
+ GNUNET_assert (sizeof (num) ==
write (client->esock,
+ &num,
+ sizeof (num)));
#else
+ GNUNET_assert (sizeof (num) ==
write (client->esock_in,
-#endif
&num,
sizeof (num)));
+#endif
}
GNUNET_assert (0 == pthread_mutex_unlock (&TES_clients_lock));
}
@@ -249,7 +252,7 @@ TES_read_work (void *cls,
recv_size = recv (client->csock,
&buf[off],
sizeof (client->iobuf) - off,
- 0);
+ 0);
if (-1 == recv_size)
{
if ( (0 == off) &&
@@ -334,23 +337,27 @@ TES_await_ready (struct TES_Client *client)
"poll");
for (int i = 0; i<2; i++)
{
+ if (
#ifdef __linux__
- if ( (pfds[i].fd == client->esock) &&
+ (pfds[i].fd == client->esock) &&
#else
- if ( (pfds[i].fd == client->esock_out) &&
+ (pfds[i].fd == client->esock_out) &&
#endif
- (POLLIN == pfds[i].revents) )
+ (POLLIN == pfds[i].revents) )
{
uint64_t num;
- GNUNET_assert (sizeof (num) ==
#ifdef __linux__
+ GNUNET_assert (sizeof (num) ==
read (client->esock,
+ &num,
+ sizeof (num)));
#else
+ GNUNET_assert (sizeof (num) ==
read (client->esock_out,
-#endif
&num,
sizeof (num)));
+#endif
return true;
}
}
diff --git a/src/util/taler-exchange-secmod-cs.c b/src/util/taler-exchange-secmod-cs.c
index 3e9ba1558..f69acd890 100644
--- a/src/util/taler-exchange-secmod-cs.c
+++ b/src/util/taler-exchange-secmod-cs.c
@@ -327,13 +327,13 @@ static int global_ret;
* Time when the key update is executed.
* Either the actual current time, or a pretended time.
*/
-static struct GNUNET_TIME_Timestamp now;
+static struct GNUNET_TIME_Timestamp global_now;
/**
* The time for the key update, as passed by the user
* on the command line.
*/
-static struct GNUNET_TIME_Timestamp now_tmp;
+static struct GNUNET_TIME_Timestamp global_now_tmp;
/**
* Where do we store the keys?
@@ -1107,7 +1107,8 @@ setup_key (struct DenominationKey *dk,
keydir,
denom->section,
(unsigned long long) (dk->anchor.abs_time.abs_value_us
- / GNUNET_TIME_UNIT_SECONDS.rel_value_us));
+ / GNUNET_TIME_UNIT_SECONDS.rel_value_us
+ ));
if (GNUNET_OK !=
GNUNET_DISK_fn_write (dk->filename,
&priv,
@@ -2185,15 +2186,17 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
- if (GNUNET_TIME_timestamp_cmp (now, !=, now_tmp))
+ if (GNUNET_TIME_timestamp_cmp (global_now,
+ !=,
+ global_now_tmp))
{
/* The user gave "--now", use it! */
- now = now_tmp;
+ global_now = global_now_tmp;
}
else
{
/* get current time again, we may be timetraveling! */
- now = GNUNET_TIME_timestamp_get ();
+ global_now = GNUNET_TIME_timestamp_get ();
}
GNUNET_asprintf (&secname,
"%s-secmod-cs",
@@ -2211,24 +2214,17 @@ run (void *cls,
global_ret = EXIT_NOTCONFIGURED;
return;
}
- GNUNET_free (secname);
if (GNUNET_OK !=
load_durations (cfg))
{
global_ret = EXIT_NOTCONFIGURED;
- return;
- }
- {
- char *secname;
-
- GNUNET_asprintf (&secname,
- "%s-secmod-cs",
- section);
- global_ret = TES_listen_start (cfg,
- secname,
- &cb);
GNUNET_free (secname);
+ return;
}
+ global_ret = TES_listen_start (cfg,
+ secname,
+ &cb);
+ GNUNET_free (secname);
if (0 != global_ret)
return;
sem_init (&worker_sem,
@@ -2258,7 +2254,7 @@ run (void *cls,
struct LoadContext lc = {
.cfg = cfg,
.ret = GNUNET_OK,
- .t = now
+ .t = global_now
};
GNUNET_assert (0 == pthread_mutex_lock (&keys_lock));
@@ -2312,7 +2308,7 @@ main (int argc,
"time",
"TIMESTAMP",
"pretend it is a different time for the update",
- &now_tmp),
+ &global_now_tmp),
GNUNET_GETOPT_option_uint ('w',
"workers",
"COUNT",
@@ -2329,7 +2325,9 @@ main (int argc,
not do this, the linker may "optimize" libtalerutil
away and skip #TALER_OS_init(), which we do need */
TALER_OS_init ();
- now_tmp = now = GNUNET_TIME_timestamp_get ();
+ global_now_tmp
+ = global_now
+ = GNUNET_TIME_timestamp_get ();
ret = GNUNET_PROGRAM_run (argc, argv,
"taler-exchange-secmod-cs",
"Handle private CS key operations for a Taler exchange",
diff --git a/src/util/taler-exchange-secmod-eddsa.c b/src/util/taler-exchange-secmod-eddsa.c
index 0b95447f7..401ac5835 100644
--- a/src/util/taler-exchange-secmod-eddsa.c
+++ b/src/util/taler-exchange-secmod-eddsa.c
@@ -371,7 +371,8 @@ setup_key (struct Key *key,
"%s/%llu",
keydir,
(unsigned long long) (key->anchor.abs_time.abs_value_us
- / GNUNET_TIME_UNIT_SECONDS.rel_value_us));
+ / GNUNET_TIME_UNIT_SECONDS.rel_value_us
+ ));
if (GNUNET_OK !=
GNUNET_DISK_fn_write (key->filename,
&priv,
@@ -1118,20 +1119,11 @@ run (void *cls,
global_ret = EXIT_NOTCONFIGURED;
return;
}
- GNUNET_free (secname);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
- {
- char *secname;
-
- GNUNET_asprintf (&secname,
- "%s-secmod-eddsa",
- section);
- global_ret = TES_listen_start (cfg,
- secname,
- &cb);
- GNUNET_free (secname);
- }
+ global_ret = TES_listen_start (cfg,
+ secname,
+ &cb);
if (0 != global_ret)
return;
/* Load keys */
diff --git a/src/util/taler-exchange-secmod-rsa.c b/src/util/taler-exchange-secmod-rsa.c
index c80e2e3c4..6be78b20e 100644
--- a/src/util/taler-exchange-secmod-rsa.c
+++ b/src/util/taler-exchange-secmod-rsa.c
@@ -294,13 +294,13 @@ static int global_ret;
* Time when the key update is executed.
* Either the actual current time, or a pretended time.
*/
-static struct GNUNET_TIME_Timestamp now;
+static struct GNUNET_TIME_Timestamp global_now;
/**
* The time for the key update, as passed by the user
* on the command line.
*/
-static struct GNUNET_TIME_Timestamp now_tmp;
+static struct GNUNET_TIME_Timestamp global_now_tmp;
/**
* Where do we store the keys?
@@ -893,7 +893,8 @@ setup_key (struct DenominationKey *dk,
keydir,
denom->section,
(unsigned long long) (dk->anchor.abs_time.abs_value_us
- / GNUNET_TIME_UNIT_SECONDS.rel_value_us));
+ / GNUNET_TIME_UNIT_SECONDS.rel_value_us
+ ));
if (GNUNET_OK !=
GNUNET_DISK_fn_write (dk->filename,
buf,
@@ -1973,15 +1974,17 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
- if (GNUNET_TIME_timestamp_cmp (now, !=, now_tmp))
+ if (GNUNET_TIME_timestamp_cmp (global_now,
+ !=,
+ global_now_tmp))
{
/* The user gave "--now", use it! */
- now = now_tmp;
+ global_now = global_now_tmp;
}
else
{
/* get current time again, we may be timetraveling! */
- now = GNUNET_TIME_timestamp_get ();
+ global_now = GNUNET_TIME_timestamp_get ();
}
GNUNET_asprintf (&secname,
"%s-secmod-rsa",
@@ -1999,24 +2002,20 @@ run (void *cls,
global_ret = EXIT_NOTCONFIGURED;
return;
}
- GNUNET_free (secname);
if (GNUNET_OK !=
load_durations (cfg))
{
global_ret = EXIT_NOTCONFIGURED;
- return;
- }
- {
- char *secname;
-
- GNUNET_asprintf (&secname,
- "%s-secmod-rsa",
- section);
- global_ret = TES_listen_start (cfg,
- secname,
- &cb);
GNUNET_free (secname);
+ return;
}
+ GNUNET_asprintf (&secname,
+ "%s-secmod-rsa",
+ section);
+ global_ret = TES_listen_start (cfg,
+ secname,
+ &cb);
+ GNUNET_free (secname);
if (0 != global_ret)
return;
sem_init (&worker_sem,
@@ -2047,7 +2046,7 @@ run (void *cls,
struct LoadContext lc = {
.cfg = cfg,
.ret = GNUNET_OK,
- .t = now
+ .t = global_now
};
GNUNET_assert (0 == pthread_mutex_lock (&keys_lock));
@@ -2101,7 +2100,7 @@ main (int argc,
"time",
"TIMESTAMP",
"pretend it is a different time for the update",
- &now_tmp),
+ &global_now_tmp),
GNUNET_GETOPT_option_uint ('w',
"workers",
"COUNT",
@@ -2118,7 +2117,9 @@ main (int argc,
not do this, the linker may "optimize" libtalerutil
away and skip #TALER_OS_init(), which we do need */
TALER_OS_init ();
- now_tmp = now = GNUNET_TIME_timestamp_get ();
+ global_now_tmp
+ = global_now
+ = GNUNET_TIME_timestamp_get ();
ret = GNUNET_PROGRAM_run (argc, argv,
"taler-exchange-secmod-rsa",
"Handle private RSA key operations for a Taler exchange",
diff --git a/src/util/tokens.c b/src/util/tokens.c
index b79dda61a..c9f68448f 100644
--- a/src/util/tokens.c
+++ b/src/util/tokens.c
@@ -235,4 +235,4 @@ TALER_token_issue_sig_unblind (
return GNUNET_SYSERR;
}
return GNUNET_OK;
-} \ No newline at end of file
+}