gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: fix NPE on key not found


From: gnunet
Subject: [taler-exchange] branch master updated: fix NPE on key not found
Date: Wed, 21 Jul 2021 18:51:11 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 5828dfad fix NPE on key not found
5828dfad is described below

commit 5828dfad1df1ff9c4f2cec18a9a85c87f7364930
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Jul 21 18:51:05 2021 +0200

    fix NPE on key not found
---
 src/exchange/taler-exchange-httpd_keys.c             | 16 +++++++++++-----
 src/exchange/taler-exchange-httpd_keys.h             |  6 ++++--
 .../taler-exchange-httpd_management_post_keys.c      | 20 ++++++++++++++++----
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_keys.c 
b/src/exchange/taler-exchange-httpd_keys.c
index b703b220..f6894a2a 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -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;
 }
 
diff --git a/src/exchange/taler-exchange-httpd_keys.h 
b/src/exchange/taler-exchange-httpd_keys.h
index 2a74304e..7494597a 100644
--- a/src/exchange/taler-exchange-httpd_keys.h
+++ b/src/exchange/taler-exchange-httpd_keys.h
@@ -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);
diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c 
b/src/exchange/taler-exchange-httpd_management_post_keys.c
index a4e8ac35..4fb65d41 100644
--- a/src/exchange/taler-exchange-httpd_management_post_keys.c
+++ b/src/exchange/taler-exchange-httpd_management_post_keys.c
@@ -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

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]