gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-mdb] branch master updated: Calculate checksum just for pro


From: gnunet
Subject: [taler-taler-mdb] branch master updated: Calculate checksum just for products
Date: Sat, 28 Dec 2019 21:46:31 +0100

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

dominik-hofer pushed a commit to branch master
in repository taler-mdb.

The following commit(s) were added to refs/heads/master by this push:
     new 71b28cb  Calculate checksum just for products
71b28cb is described below

commit 71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c
Author: Dominik Hofer <address@hidden>
AuthorDate: Sat Dec 28 21:45:41 2019 +0100

    Calculate checksum just for products
---
 src/main.c | 59 ++++++++++++++++++++++++++++-------------------------------
 1 file changed, 28 insertions(+), 31 deletions(-)

diff --git a/src/main.c b/src/main.c
index e98a68b..b85578f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1935,37 +1935,6 @@ handle_command (const char *hex,
     return;
   }
        
-  /* Calculate the checksum and check it */
-       if (4 < hex_len)
-       {
-               chkSum = cmd;
-
-       for( size_t offset = 1; offset < ((hex_len / 2)); offset++ ){
-                       chkSum += tmp;
-                       if (1 != sscanf (hex + (2 * offset),
-                        "%2X",
-                        &tmp))
-               {
-         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                     "Received non-HEX input `%.*s'\n",
-                     (int) hex_len,
-                     hex);
-         GNUNET_break_op (0);
-         return;
-               }
-               }
-               if ( ((uint8_t) (chkSum & 0xFF)) != tmp )
-               {
-                       mdb.cmd = &readerDisplayInternalError;
-                       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                     "Received command with wrong checksum `%.*s'\n",
-                     (int) hex_len,
-                     hex);
-         return;
-
-               }
-       }
-
          /* parse the first byte (cmd) and the second byte (subcmd) */
   switch (cmd)
   {
@@ -1994,6 +1963,34 @@ handle_command (const char *hex,
       {
       case VMC_VEND_REQUEST:
         {
+       
+                               /* Calculate the checksum and check it */
+                                       chkSum = cmd;
+
+                               for( size_t offset = 1; offset < ((hex_len / 
2)); offset++ ){
+                                               chkSum += tmp;
+                                               if (1 != sscanf (hex + (2 * 
offset),
+                                                "%2X",
+                                                &tmp))
+                                       {
+                                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                                             "Received non-HEX input `%.*s'\n",
+                                             (int) hex_len,
+                                             hex);
+                                 GNUNET_break_op (0);
+                                 return;
+                                       }
+                                       }
+                                       if ( ((uint8_t) (chkSum & 0xFF)) != tmp 
)
+                                       {
+                                               mdb.cmd = 
&readerDisplayInternalError;
+                                               GNUNET_log 
(GNUNET_ERROR_TYPE_WARNING,
+                                             "Received command with wrong 
checksum `%.*s'\n",
+                                             (int) hex_len,
+                                             hex);
+                                 break;
+
+                                       }
           unsigned int product;
 
           GNUNET_break (GNUNET_YES == mdb.session_running);

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



reply via email to

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