minor bugfixes

This commit is contained in:
Christian Grothoff 2015-05-01 09:59:18 +02:00
parent e591651937
commit 95f99d32dd
2 changed files with 17 additions and 11 deletions

View File

@ -548,7 +548,13 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
break; break;
} }
} }
if (0 == ret)
{
/* history is empty!? */
GNUNET_break (0);
json_decref (json_history);
return NULL;
}
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
TALER_amount_subtract (balance, TALER_amount_subtract (balance,
&deposit_total, &deposit_total,

View File

@ -290,7 +290,7 @@ TALER_refresh_link_encrypted_decode (const char *buf,
{ {
struct TALER_RefreshLinkEncrypted *rle; struct TALER_RefreshLinkEncrypted *rle;
if (buf_len < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) if (buf_len < sizeof (union TALER_CoinSpendPrivateKeyP))
return NULL; return NULL;
if (buf_len >= GNUNET_MAX_MALLOC_CHECKED) if (buf_len >= GNUNET_MAX_MALLOC_CHECKED)
{ {
@ -298,9 +298,9 @@ TALER_refresh_link_encrypted_decode (const char *buf,
return NULL; return NULL;
} }
rle = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) + rle = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) +
buf_len - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)); buf_len - sizeof (union TALER_CoinSpendPrivateKeyP));
rle->blinding_key_enc = (const char *) &rle[1]; rle->blinding_key_enc = (const char *) &rle[1];
rle->blinding_key_enc_size = buf_len - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey); rle->blinding_key_enc_size = buf_len - sizeof (union TALER_CoinSpendPrivateKeyP);
memcpy (rle->coin_priv_enc, memcpy (rle->coin_priv_enc,
buf, buf,
buf_len); buf_len);
@ -321,12 +321,12 @@ TALER_refresh_link_encrypted_encode (const struct TALER_RefreshLinkEncrypted *rl
{ {
char *buf; char *buf;
if (rle->blinding_key_enc_size >= GNUNET_MAX_MALLOC_CHECKED - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) if (rle->blinding_key_enc_size >= GNUNET_MAX_MALLOC_CHECKED - sizeof (union TALER_CoinSpendPrivateKeyP))
{ {
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }
*buf_len = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey) + rle->blinding_key_enc_size; *buf_len = sizeof (union TALER_CoinSpendPrivateKeyP) + rle->blinding_key_enc_size;
buf = GNUNET_malloc (*buf_len); buf = GNUNET_malloc (*buf_len);
memcpy (buf, memcpy (buf,
rle->coin_priv_enc, rle->coin_priv_enc,
@ -369,7 +369,7 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info)
* Decrypt the shared @a secret from the information in the * Decrypt the shared @a secret from the information in the
* encrypted link secret @e secret_enc using the transfer * encrypted link secret @e secret_enc using the transfer
* private key and the coin's public key. * private key and the coin's public key.
* *
* @param secret_enc encrypted link secret * @param secret_enc encrypted link secret
* @param transfer_priv transfer private key * @param transfer_priv transfer private key
* @param coin_pub coin public key * @param coin_pub coin public key
@ -408,7 +408,7 @@ TALER_link_decrypt_secret (const struct TALER_EncryptedLinkSecretP *secret_enc,
* Decrypt the shared @a secret from the information in the * Decrypt the shared @a secret from the information in the
* encrypted link secret @e secret_enc using the transfer * encrypted link secret @e secret_enc using the transfer
* public key and the coin's private key. * public key and the coin's private key.
* *
* @param secret_enc encrypted link secret * @param secret_enc encrypted link secret
* @param transfer_pub transfer public key * @param transfer_pub transfer public key
* @param coin_priv coin private key * @param coin_priv coin private key
@ -425,7 +425,7 @@ TALER_link_decrypt_secret2 (const struct TALER_EncryptedLinkSecretP *secret_enc,
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_ecc_ecdh (&coin_priv->ecdhe_priv, GNUNET_CRYPTO_ecc_ecdh (&coin_priv->ecdhe_priv,
&trans_pub->ecdhe_pub, &trans_pub->ecdhe_pub,
&transfer_secret.key)) &transfer_secret.key))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -446,8 +446,8 @@ TALER_link_decrypt_secret2 (const struct TALER_EncryptedLinkSecretP *secret_enc,
/** /**
* Encrypt the shared @a secret to generate the encrypted link secret. * Encrypt the shared @a secret to generate the encrypted link secret.
* Also creates the transfer key. * Also creates the transfer key.
* *
* @param secret link secret to encrypt * @param secret link secret to encrypt
* @param coin_pub coin public key * @param coin_pub coin public key
* @param transfer_priv[out] set to transfer private key * @param transfer_priv[out] set to transfer private key
* @param transfer_pub[out] set to transfer public key * @param transfer_pub[out] set to transfer public key