summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);