diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-23 12:50:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-23 12:51:07 +0200 |
commit | e7e10a2931cc19969b2c060a0996506e5b7ce43e (patch) | |
tree | 377da45437911a06a8014aead814f2719b06bcd6 /src/reducer/anastasis_api_recovery_redux.c | |
parent | c533c5441456cb81e64be24f52eb1ee35ee3243e (diff) | |
download | anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.tar.gz anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.tar.bz2 anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.zip |
-misc bugfixes for IBAN plugin
Diffstat (limited to 'src/reducer/anastasis_api_recovery_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_recovery_redux.c | 90 |
1 files changed, 30 insertions, 60 deletions
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c index 5513e83..c29a08a 100644 --- a/src/reducer/anastasis_api_recovery_redux.c +++ b/src/reducer/anastasis_api_recovery_redux.c @@ -635,7 +635,6 @@ answer_feedback_cb ( uuid, err)); } - GNUNET_break_op (0); set_state (sctx->state, ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING); sctx->cb (sctx->cb_cls, @@ -711,79 +710,50 @@ answer_feedback_cb ( case ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS: { - json_t *body = NULL; - const char *mime; + const json_t *body = csr->details.external_challenge; + const char *method; + json_t *details; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_string ("method", + &method), + GNUNET_JSON_spec_json ("details", + &details), + GNUNET_JSON_spec_end () + }; + json_t *reply; - mime = csr->details.open_challenge.content_type; - if (0 == strcasecmp (mime, - "application/json")) - { - body = json_loadb (csr->details.open_challenge.body, - csr->details.open_challenge.body_size, - JSON_REJECT_DUPLICATES, - NULL); - GNUNET_break_op (NULL != body); - } - if (NULL == body) + if (GNUNET_OK != + GNUNET_JSON_parse (body, + spec, + NULL, NULL)) { json_t *err; + GNUNET_break_op (0); err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "server-failure"), GNUNET_JSON_pack_uint64 ("error_code", - TALER_EC_GENERIC_INVALID_RESPONSE)); + TALER_EC_GENERIC_REPLY_MALFORMED)); GNUNET_assert (0 == json_object_set_new (feedback, uuid, err)); + return; } - else - { - const char *method; - json_t *details; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("method", - &method), - GNUNET_JSON_spec_json ("details", - &details), - GNUNET_JSON_spec_end () - }; - json_t *reply; - if (GNUNET_OK != - GNUNET_JSON_parse (body, - spec, - NULL, NULL)) - { - json_t *err; - - GNUNET_break_op (0); - err = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("state", - "server-failure"), - GNUNET_JSON_pack_uint64 ("error_code", - TALER_EC_GENERIC_REPLY_MALFORMED)); - GNUNET_assert (0 == - json_object_set_new (feedback, - uuid, - err)); - return; - } - - reply = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("state", - "external-instructions"), - GNUNET_JSON_pack_string ("method", - method), - GNUNET_JSON_pack_object_incref ("details", - details)); - GNUNET_JSON_parse_free (spec); - GNUNET_assert (0 == - json_object_set_new (feedback, - uuid, - reply)); - } + reply = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("state", + "external-instructions"), + GNUNET_JSON_pack_string ("method", + method), + GNUNET_JSON_pack_object_incref ("details", + details)); + GNUNET_JSON_parse_free (spec); + GNUNET_assert (0 == + json_object_set_new (feedback, + uuid, + reply)); } set_state (sctx->state, ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING); |