summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-11-25 16:04:47 +0900
committerChristian Grothoff <grothoff@gnunet.org>2023-11-25 16:04:47 +0900
commitbb9063319eaba3fda88bcbbf17806eac8249e142 (patch)
treecf38cb98fa5be51a5307d600b39de2c1b6c3040a
parent1d2021d42c4bf78fab9ecc892686c26d76096ca0 (diff)
downloadanastasis-bb9063319eaba3fda88bcbbf17806eac8249e142.tar.gz
anastasis-bb9063319eaba3fda88bcbbf17806eac8249e142.tar.bz2
anastasis-bb9063319eaba3fda88bcbbf17806eac8249e142.zip
-update to new spec parsers for better error checking
-rw-r--r--src/lib/anastasis_recovery.c6
-rw-r--r--src/restclient/anastasis_api_config.c56
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);
{