fix NPE on key not found
This commit is contained in:
parent
3721780f16
commit
5828dfad1d
@ -2152,7 +2152,7 @@ TEH_keys_get_handler (const struct TEH_RequestHandler *rh,
|
||||
* @param[in,out] meta denomination type data to complete
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static int
|
||||
static enum GNUNET_GenericReturnValue
|
||||
load_fees (const char *section_name,
|
||||
struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
|
||||
{
|
||||
@ -2271,14 +2271,14 @@ load_fees (const char *section_name,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
enum GNUNET_GenericReturnValue
|
||||
TEH_keys_load_fees (const struct GNUNET_HashCode *h_denom_pub,
|
||||
struct TALER_DenominationPublicKey *denom_pub,
|
||||
struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
|
||||
{
|
||||
struct TEH_KeyStateHandle *ksh;
|
||||
struct HelperDenomination *hd;
|
||||
int ok;
|
||||
enum GNUNET_GenericReturnValue ok;
|
||||
|
||||
ksh = get_key_state (true);
|
||||
if (NULL == ksh)
|
||||
@ -2289,6 +2289,13 @@ TEH_keys_load_fees (const struct GNUNET_HashCode *h_denom_pub,
|
||||
|
||||
hd = GNUNET_CONTAINER_multihashmap_get (ksh->helpers->denom_keys,
|
||||
h_denom_pub);
|
||||
if (NULL == hd)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Denomination %s not known\n",
|
||||
GNUNET_h2s (h_denom_pub));
|
||||
return GNUNET_NO;
|
||||
}
|
||||
meta->start = hd->start_time;
|
||||
meta->expire_withdraw = GNUNET_TIME_absolute_add (meta->start,
|
||||
hd->validity_duration);
|
||||
@ -2298,8 +2305,7 @@ TEH_keys_load_fees (const struct GNUNET_HashCode *h_denom_pub,
|
||||
denom_pub->rsa_public_key
|
||||
= GNUNET_CRYPTO_rsa_public_key_dup (hd->denom_pub.rsa_public_key);
|
||||
else
|
||||
denom_pub->rsa_public_key
|
||||
= NULL;
|
||||
denom_pub->rsa_public_key = NULL;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -356,9 +356,11 @@ TEH_keys_management_get_handler (const struct TEH_RequestHandler *rh,
|
||||
* to use to derive the section name of the configuration to use
|
||||
* @param[out] denom_pub set to the denomination public key (to be freed by caller!)
|
||||
* @param[out] meta denomination type data to complete
|
||||
* @return #GNUNET_OK on success
|
||||
* @return #GNUNET_OK on success,
|
||||
* #GNUNET_NO if @a h_denom_pub is not known
|
||||
* #GNUNET_SYSERR on hard errors
|
||||
*/
|
||||
int
|
||||
enum GNUNET_GenericReturnValue
|
||||
TEH_keys_load_fees (const struct GNUNET_HashCode *h_denom_pub,
|
||||
struct TALER_DenominationPublicKey *denom_pub,
|
||||
struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta);
|
||||
|
@ -147,17 +147,29 @@ add_keys (void *cls,
|
||||
}
|
||||
if (0 == qs)
|
||||
{
|
||||
if (GNUNET_OK !=
|
||||
TEH_keys_load_fees (&akc->d_sigs[i].h_denom_pub,
|
||||
&denom_pub,
|
||||
&meta))
|
||||
enum GNUNET_GenericReturnValue rv;
|
||||
|
||||
rv = TEH_keys_load_fees (&akc->d_sigs[i].h_denom_pub,
|
||||
&denom_pub,
|
||||
&meta);
|
||||
switch (rv)
|
||||
{
|
||||
case GNUNET_SYSERR:
|
||||
*mhd_ret = TALER_MHD_reply_with_error (
|
||||
connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION,
|
||||
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub));
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
case GNUNET_NO:
|
||||
*mhd_ret = TALER_MHD_reply_with_error (
|
||||
connection,
|
||||
MHD_HTTP_NOT_FOUND,
|
||||
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN,
|
||||
GNUNET_h2s (&akc->d_sigs[i].h_denom_pub));
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
case GNUNET_OK:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user