diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-11-27 12:15:08 +0900 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-11-27 12:15:08 +0900 |
commit | 152c0f1edc1ac0a7a82982bda4e4e844c7964315 (patch) | |
tree | 02f954b0f9dfeaec1ed7785a892b787c478a5849 /src/json | |
parent | acaf8ffa2422d3023280c420ad5fc7c0eb58d134 (diff) |
-fix new JSON parsers
Diffstat (limited to 'src/json')
-rw-r--r-- | src/json/json_helper.c | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 19dec2170..0628282ca 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -1440,21 +1440,16 @@ parse_ec (void *cls, struct GNUNET_JSON_Specification *spec) { enum TALER_ErrorCode *ec = spec->ptr; - uint32_t num; - struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 (spec->field, - &num), - GNUNET_JSON_spec_end () - }; - const char *emsg; - unsigned int eline; + json_int_t num; (void) cls; - if (GNUNET_OK != - GNUNET_JSON_parse (root, - dspec, - &emsg, - &eline)) + if (! json_is_integer (root)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + num = json_integer_value (root); + if (num < 0) { GNUNET_break_op (0); *ec = TALER_EC_INVALID; @@ -1494,26 +1489,17 @@ parse_aml_decision (void *cls, struct GNUNET_JSON_Specification *spec) { enum TALER_AmlDecisionState *aml = spec->ptr; - uint32_t num; - struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_uint32 (spec->field, - &num), - GNUNET_JSON_spec_end () - }; - const char *emsg; - unsigned int eline; + json_int_t num; (void) cls; - if (GNUNET_OK != - GNUNET_JSON_parse (root, - dspec, - &emsg, - &eline)) + if (! json_is_integer (root)) { GNUNET_break_op (0); return GNUNET_SYSERR; } - if (num > TALER_AML_MAX) + num = json_integer_value (root); + if ( (num > TALER_AML_MAX) || + (num < 0) ) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -1649,25 +1635,15 @@ parse_protocol_version (void *cls, { struct TALER_JSON_ProtocolVersion *pv = spec->ptr; const char *ver; - struct GNUNET_JSON_Specification dspec[] = { - GNUNET_JSON_spec_string (spec->field, - &ver), - GNUNET_JSON_spec_end () - }; - const char *emsg; - unsigned int eline; char dummy; (void) cls; - if (GNUNET_OK != - GNUNET_JSON_parse (root, - dspec, - &emsg, - &eline)) + if (! json_is_string (root)) { GNUNET_break_op (0); return GNUNET_SYSERR; } + ver = json_string_value (root); if (3 != sscanf (ver, "%u:%u:%u%c", &pv->current, |