gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: -update to new spec parsers for


From: gnunet
Subject: [taler-anastasis] branch master updated: -update to new spec parsers for better error checking
Date: Sat, 25 Nov 2023 14:51:03 +0100

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new bb90633  -update to new spec parsers for better error checking
bb90633 is described below

commit bb9063319eaba3fda88bcbbf17806eac8249e142
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sat Nov 25 16:04:47 2023 +0900

    -update to new spec parsers for better error checking
---
 src/lib/anastasis_recovery.c          |  6 ++--
 src/restclient/anastasis_api_config.c | 56 +++++++++++++----------------------
 2 files changed, 23 insertions(+), 39 deletions(-)

diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 0364b5a..f164c93 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -821,7 +821,7 @@ policy_lookup_cb (void *cls,
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("uuid",
                                    &cs->ci.uuid),
-      GNUNET_JSON_spec_string ("url",
+      TALER_JSON_spec_web_url ("url",
                                &url),
       GNUNET_JSON_spec_string ("instructions",
                                &instructions),
@@ -1150,7 +1150,7 @@ parse_cs_array (struct ANASTASIS_Recovery *r,
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("uuid",
                                    &c->ci.uuid),
-      GNUNET_JSON_spec_string ("url",
+      TALER_JSON_spec_web_url ("url",
                                &url),
       GNUNET_JSON_spec_string ("instructions",
                                &instructions),
@@ -1355,7 +1355,7 @@ ANASTASIS_recovery_deserialize (struct 
GNUNET_CURL_Context *ctx,
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("id",
                                    &r->id),
-      GNUNET_JSON_spec_string ("provider_url",
+      TALER_JSON_spec_web_url ("provider_url",
                                &provider_url),
       GNUNET_JSON_spec_mark_optional (
         GNUNET_JSON_spec_string ("secret_name",
diff --git a/src/restclient/anastasis_api_config.c 
b/src/restclient/anastasis_api_config.c
index f82cd9e..fff4774 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -104,6 +104,7 @@ handle_config_finished (void *cls,
     {
       const char *name;
       const json_t *methods;
+      struct TALER_JSON_ProtocolVersion pv;
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_string ("name",
                                  &name),
@@ -111,6 +112,8 @@ handle_config_finished (void *cls,
                                  &acfg.details.ok.business_name),
         GNUNET_JSON_spec_string ("version",
                                  &acfg.details.ok.version),
+        TALER_JSON_spec_version ("version",
+                                 &pv),
         GNUNET_JSON_spec_array_const ("methods",
                                       &methods),
         GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
@@ -147,43 +150,24 @@ handle_config_finished (void *cls,
         acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
         break;
       }
+      if ( (ANASTASIS_PROTOCOL_CURRENT < pv.current) &&
+           (ANASTASIS_PROTOCOL_CURRENT < pv.current - pv.age) )
       {
-        unsigned int age;
-        unsigned int revision;
-        unsigned int current;
-        char dummy;
-
-        if (3 != sscanf (acfg.details.ok.version,
-                         "%u:%u:%u%c",
-                         &current,
-                         &revision,
-                         &age,
-                         &dummy))
-        {
-          GNUNET_break_op (0);
-          acfg.http_status = 0;
-          acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
-          break;
-        }
-        if ( (ANASTASIS_PROTOCOL_CURRENT < current) &&
-             (ANASTASIS_PROTOCOL_CURRENT < current - age) )
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Provider protocol version too new\n");
-          acfg.http_status = 0;
-          acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
-          break;
-        }
-        if ( (ANASTASIS_PROTOCOL_CURRENT > current) &&
-             (ANASTASIS_PROTOCOL_CURRENT - ANASTASIS_PROTOCOL_AGE > current) )
-        {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      "Provider protocol version too old\n");
-          GNUNET_break_op (0);
-          acfg.http_status = 0;
-          acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
-          break;
-        }
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Provider protocol version too new\n");
+        acfg.http_status = 0;
+        acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
+        break;
+      }
+      if ( (ANASTASIS_PROTOCOL_CURRENT > pv.current) &&
+           (ANASTASIS_PROTOCOL_CURRENT - ANASTASIS_PROTOCOL_AGE > pv.current) )
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Provider protocol version too old\n");
+        GNUNET_break_op (0);
+        acfg.http_status = 0;
+        acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
+        break;
       }
       acfg.details.ok.methods_length = json_array_size (methods);
       {

-- 
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]