diff options
author | Dominik Hofer <dominik.hofer@bfh.ch> | 2019-12-28 21:45:41 +0100 |
---|---|---|
committer | Dominik Hofer <dominik.hofer@bfh.ch> | 2019-12-28 21:45:41 +0100 |
commit | 71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c (patch) | |
tree | 83dcb7ffb61c8745e15335f6072dcc16017dfbc8 /src | |
parent | 22b5964470d94535e27164e84f762a149c1ad680 (diff) | |
download | taler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.tar.gz taler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.tar.bz2 taler-mdb-71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c.zip |
Calculate checksum just for products
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 59 |
1 files changed, 28 insertions, 31 deletions
@@ -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); |