gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: fix logic error


From: gnunet
Subject: [taler-anastasis] branch master updated: fix logic error
Date: Sun, 07 Mar 2021 16:58:11 +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 46c9777  fix logic error
46c9777 is described below

commit 46c97778d0b78d8b46ea2878b5f27638886c9b4e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Mar 7 16:58:09 2021 +0100

    fix logic error
---
 ...tasis_reducer_recovery_enter_user_attributes.sh |   6 +
 src/reducer/anastasis_api_recovery_redux.c         | 236 ++++++++++-----------
 2 files changed, 123 insertions(+), 119 deletions(-)

diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index 7d4853d..10499cc 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -397,6 +397,12 @@ echo -n "Running challenge logic ..."
 UUID0=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
 UUID1=`jq -r -e .recovery_information.challenges[1].uuid < $R2FILE`
 
+export UUID0
+export UUID1
+export R1FILE
+export R2FILE
+bash
+
 anastasis-reducer -a \
   "$(jq -n '
     {
diff --git a/src/reducer/anastasis_api_recovery_redux.c 
b/src/reducer/anastasis_api_recovery_redux.c
index a66889e..54bf71e 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -577,6 +577,10 @@ run_challenge_cb (void *cls,
     int ret;
 
     cd = ANASTASIS_challenge_get_details (ci);
+    if (0 !=
+        GNUNET_memcmp (&sctx->uuid,
+                       &cd->uuid))
+      continue;
     if (cd->solved)
     {
       ANASTASIS_redux_fail_ (sctx->cb,
@@ -586,103 +590,98 @@ run_challenge_cb (void *cls,
       sctx_free (sctx);
       return;
     }
-    if (0 ==
-        GNUNET_memcmp (&sctx->uuid,
-                       &cd->uuid))
+    if (0 == strcmp ("question",
+                     cd->type))
+    {
+      /* security question, answer must be a string */
+      json_t *janswer = json_object_get (sctx->args,
+                                         "answer");
+      const char *answer = json_string_value (janswer);
+
+      if (NULL == answer)
+      {
+        ANASTASIS_redux_fail_ (sctx->cb,
+                               sctx->cb_cls,
+                               TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+                               "'answer' missing");
+        sctx_free (sctx);
+        return;
+      }
+      /* persist answer, in case payment is required */
+      GNUNET_assert (0 ==
+                     json_object_set (challenge,
+                                      "answer",
+                                      janswer));
+      ret = ANASTASIS_challenge_answer (ci,
+                                        psp,
+                                        answer,
+                                        &answer_feedback_cb,
+                                        sctx);
+    }
+    else
     {
-      if (0 == strcmp ("question",
-                       cd->type))
+      /* Check if we got a PIN or a HASH */
+      json_t *pin = json_object_get (sctx->args,
+                                     "pin");
+      json_t *hash = json_object_get (sctx->args,
+                                      "hash");
+      if (json_is_integer (pin))
       {
-        /* security question, answer must be a string */
-        json_t *janswer = json_object_get (sctx->args,
-                                           "answer");
-        const char *answer = json_string_value (janswer);
+        uint64_t ianswer = json_integer_value (pin);
 
-        if (NULL == answer)
+        ret = ANASTASIS_challenge_answer2 (ci,
+                                           psp,
+                                           ianswer,
+                                           &answer_feedback_cb,
+                                           sctx);
+      }
+      else if (NULL != hash)
+      {
+        struct GNUNET_HashCode hashed_answer;
+        struct GNUNET_JSON_Specification spec[] = {
+          GNUNET_JSON_spec_fixed_auto ("hash",
+                                       &hashed_answer),
+          GNUNET_JSON_spec_end ()
+        };
+
+        if (GNUNET_OK !=
+            GNUNET_JSON_parse (sctx->args,
+                               spec,
+                               NULL, NULL))
         {
           ANASTASIS_redux_fail_ (sctx->cb,
                                  sctx->cb_cls,
                                  TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
-                                 "'answer' missing");
+                                 "'answer' malformed");
           sctx_free (sctx);
           return;
         }
-        /* persist answer, in case payment is required */
-        GNUNET_assert (0 ==
-                       json_object_set (challenge,
-                                        "answer",
-                                        janswer));
-        ret = ANASTASIS_challenge_answer (ci,
-                                          psp,
-                                          answer,
-                                          &answer_feedback_cb,
-                                          sctx);
+        ret = ANASTASIS_challenge_start (ci,
+                                         psp,
+                                         &hashed_answer,
+                                         &answer_feedback_cb,
+                                         sctx);
       }
       else
       {
-        /* Check if we got a PIN or a HASH */
-        json_t *pin = json_object_get (sctx->args,
-                                       "pin");
-        json_t *hash = json_object_get (sctx->args,
-                                        "hash");
-        if (json_is_integer (pin))
-        {
-          uint64_t ianswer = json_integer_value (pin);
-
-          ret = ANASTASIS_challenge_answer2 (ci,
-                                             psp,
-                                             ianswer,
-                                             &answer_feedback_cb,
-                                             sctx);
-        }
-        else if (NULL != hash)
-        {
-          struct GNUNET_HashCode hashed_answer;
-          struct GNUNET_JSON_Specification spec[] = {
-            GNUNET_JSON_spec_fixed_auto ("hash",
-                                         &hashed_answer),
-            GNUNET_JSON_spec_end ()
-          };
-
-          if (GNUNET_OK !=
-              GNUNET_JSON_parse (sctx->args,
-                                 spec,
-                                 NULL, NULL))
-          {
-            ANASTASIS_redux_fail_ (sctx->cb,
-                                   sctx->cb_cls,
-                                   TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
-                                   "'answer' malformed");
-            sctx_free (sctx);
-            return;
-          }
-          ret = ANASTASIS_challenge_start (ci,
-                                           psp,
-                                           &hashed_answer,
-                                           &answer_feedback_cb,
-                                           sctx);
-        }
-        else
-        {
-          /* no answer provided */
-          ret = ANASTASIS_challenge_start (ci,
-                                           psp,
-                                           NULL, /* no answer */
-                                           &answer_feedback_cb,
-                                           sctx);
-        }
-      }
-      if (GNUNET_OK != ret)
-      {
-        ANASTASIS_redux_fail_ (sctx->cb,
-                               sctx->cb_cls,
-                               TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
-                               "Failed to begin answering challenge");
-        sctx_free (sctx);
-        return;
+        /* no answer provided */
+        ret = ANASTASIS_challenge_start (ci,
+                                         psp,
+                                         NULL,   /* no answer */
+                                         &answer_feedback_cb,
+                                         sctx);
       }
-      return; /* await answer feedback */
     }
+    if (GNUNET_OK != ret)
+    {
+      ANASTASIS_redux_fail_ (sctx->cb,
+                             sctx->cb_cls,
+                             TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+                             "Failed to begin answering challenge");
+      sctx_free (sctx);
+      return;
+    }
+    return;   /* await answer feedback */
   }
   ANASTASIS_redux_fail_ (sctx->cb,
                          sctx->cb_cls,
@@ -747,6 +746,10 @@ pay_challenge_cb (void *cls,
     int ret;
 
     cd = ANASTASIS_challenge_get_details (ci);
+    if (0 !=
+        GNUNET_memcmp (&sctx->uuid,
+                       &cd->uuid))
+      continue;
     if (cd->solved)
     {
       ANASTASIS_redux_fail_ (sctx->cb,
@@ -757,52 +760,47 @@ pay_challenge_cb (void *cls,
       return;
     }
 
-    if (0 ==
-        GNUNET_memcmp (&sctx->uuid,
-                       &cd->uuid))
+    if (0 == strcmp ("question",
+                     cd->type))
     {
-      if (0 == strcmp ("question",
-                       cd->type))
-      {
-        /* security question, answer must be a string and already ready */
-        json_t *janswer = json_object_get (challenge,
-                                           "answer");
-        const char *answer = json_string_value (janswer);
+      /* security question, answer must be a string and already ready */
+      json_t *janswer = json_object_get (challenge,
+                                         "answer");
+      const char *answer = json_string_value (janswer);
 
-        if (NULL == answer)
-        {
-          ANASTASIS_redux_fail_ (sctx->cb,
-                                 sctx->cb_cls,
-                                 TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
-                                 "'answer' missing");
-          sctx_free (sctx);
-          return;
-        }
-        ret = ANASTASIS_challenge_answer (ci,
-                                          &sctx->ps,
-                                          answer,
-                                          &answer_feedback_cb,
-                                          sctx);
-      }
-      else
-      {
-        ret = ANASTASIS_challenge_start (ci,
-                                         &sctx->ps,
-                                         NULL, /* no answer yet */
-                                         &answer_feedback_cb,
-                                         sctx);
-      }
-      if (GNUNET_OK != ret)
+      if (NULL == answer)
       {
         ANASTASIS_redux_fail_ (sctx->cb,
                                sctx->cb_cls,
-                               TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
-                               "Failed to begin answering challenge");
+                               TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+                               "'answer' missing");
         sctx_free (sctx);
         return;
       }
-      return; /* await answer feedback */
+      ret = ANASTASIS_challenge_answer (ci,
+                                        &sctx->ps,
+                                        answer,
+                                        &answer_feedback_cb,
+                                        sctx);
     }
+    else
+    {
+      ret = ANASTASIS_challenge_start (ci,
+                                       &sctx->ps,
+                                       NULL,   /* no answer yet */
+                                       &answer_feedback_cb,
+                                       sctx);
+    }
+    if (GNUNET_OK != ret)
+    {
+      ANASTASIS_redux_fail_ (sctx->cb,
+                             sctx->cb_cls,
+                             TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+                             "Failed to begin answering challenge");
+      sctx_free (sctx);
+      return;
+    }
+    return;   /* await answer feedback */
   }
   ANASTASIS_redux_fail_ (sctx->cb,
                          sctx->cb_cls,

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