summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Hofer <dominik.hofer@bfh.ch>2019-12-28 21:45:41 +0100
committerDominik Hofer <dominik.hofer@bfh.ch>2019-12-28 21:45:41 +0100
commit71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c (patch)
tree83dcb7ffb61c8745e15335f6072dcc16017dfbc8
parent22b5964470d94535e27164e84f762a149c1ad680 (diff)
downloadtaler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.tar.gz
taler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.tar.bz2
taler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.zip
Calculate checksum just for products
-rw-r--r--src/main.c59
1 files 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);