gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: log


From: gnunet
Subject: [taler-anastasis] branch master updated: log
Date: Mon, 21 Dec 2020 13:16:05 +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 e551940  log
e551940 is described below

commit e551940c39a50a53f31e41b1d1604276a4411428
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Dec 21 13:16:03 2020 +0100

    log
---
 src/lib/anastasis_api_redux.c | 50 +++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 69a1895..e1e641e 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -490,7 +490,6 @@ static bool
 validate_ahv (const char *ahv_number,
               const char *regexp)
 {
-  unsigned int checknum;
   char num_to_check[12];
   regex_t regex;
   int regex_result;
@@ -514,6 +513,9 @@ validate_ahv (const char *ahv_number,
                           0);
   if (0 != regex_result)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "AHV number `%s' does not match regex\n",
+                ahv_number);
     regfree (&regex);
     return false;
   }
@@ -543,27 +545,37 @@ validate_ahv (const char *ahv_number,
       num_to_check[i] = ahv_number[i];
     }
   }
-  int calculation = 0;
-  int next_ten = 0;
-  checknum = (int) ahv_number[strlen (ahv_number) - 1] - 48;
 
-  for (unsigned int i = 0; i < strlen (num_to_check); i++)
   {
-    int x = (int) num_to_check[strlen (num_to_check) - i - 1] - 48;
-    if (0 == i % 2)
-      calculation = calculation + (x * 3);
-    else
-      calculation = calculation + x;
+    unsigned int checknum;
+    unsigned int calculation = 0;
+    unsigned int next_ten;
+
+    checknum = (unsigned int) ahv_number[strlen (ahv_number) - 1] - 48;
+    for (size_t i = 0; i < strlen (num_to_check); i++)
+    {
+      unsigned int x = num_to_check[strlen (num_to_check) - i - 1] - 48;
+      if (0 == i % 2)
+        calculation += (x * 3);
+      else
+        calculation += x;
+    }
+    // round up to the next ten
+    next_ten = (calculation + 10) / 10;
+    next_ten = next_ten * 10;
+    // calculate check number
+    calculation = next_ten - calculation;
+
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Checksum calculation for AHV `%s' (%s) %s (%u/%u/%u)\n",
+                ahv_number,
+                num_to_check,
+                (checknum != calculation) ? "failed" : "succeeded",
+                next_ten,
+                calculation,
+                checknum);
+    return (checknum == calculation);
   }
-  // round up to the next ten
-  next_ten = (calculation + 10) / 10;
-  next_ten = next_ten * 10;
-  // calculate check number
-  calculation = next_ten - calculation;
-
-  if (checknum == calculation)
-    return true;
-  return false;
 }
 
 

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