gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: use memcpy/memcmp instead of str


From: gnunet
Subject: [taler-exchange] branch master updated: use memcpy/memcmp instead of str-functions where applicable
Date: Sun, 01 Mar 2020 13:36:43 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new f457e133 use memcpy/memcmp instead of str-functions where applicable
f457e133 is described below

commit f457e1332d5963b661741cff8ce2068fa83f5224
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Mar 1 13:36:40 2020 +0100

    use memcpy/memcmp instead of str-functions where applicable
---
 src/json/json_wire.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/json/json_wire.c b/src/json/json_wire.c
index b0bb6750..45136bf3 100644
--- a/src/json/json_wire.c
+++ b/src/json/json_wire.c
@@ -200,7 +200,7 @@ static const struct CountryTableEntry country_table[] = {
  *
  * @param ptr1 pointer to a `struct table_entry`
  * @param ptr2 pointer to a `struct table_entry`
- * @return result of strncmp()'ing the 2-digit country codes of the entries
+ * @return result of memcmp()'ing the 2-digit country codes of the entries
  */
 static int
 cmp_country_code (const void *ptr1,
@@ -209,9 +209,9 @@ cmp_country_code (const void *ptr1,
   const struct CountryTableEntry *cc1 = ptr1;
   const struct CountryTableEntry *cc2 = ptr2;
 
-  return strncmp (cc1->code,
-                  cc2->code,
-                  2);
+  return memcmp (cc1->code,
+                 cc2->code,
+                 2);
 }
 
 
@@ -242,9 +242,9 @@ validate_iban (const char *iban)
                 "IBAN number too long to be valid\n");
     return GNUNET_NO;
   }
-  strncpy (cc, iban, 2);
-  strncpy (ibancpy, iban + 4, len - 4);
-  strncpy (ibancpy + len - 4, iban, 4);
+  memcpy (cc, iban, 2);
+  memcpy (ibancpy, iban + 4, len - 4);
+  memcpy (ibancpy + len - 4, iban, 4);
   ibancpy[len] = '\0';
   cc_entry.code = cc;
   cc_entry.english = NULL;
@@ -303,11 +303,14 @@ validate_iban (const char *iban)
     remainder = dividend % 97;
   }
   GNUNET_free (nbuf);
-  if (1 == remainder)
-    return GNUNET_YES;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "IBAN checksum wrong\n");
-  return GNUNET_NO;
+  if (1 != remainder)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "IBAN `%s' has the wrong checksum\n",
+                iban);
+    return GNUNET_NO;
+  }
+  return GNUNET_YES;
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]