]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #533 from merlokk/chktd
authorIceman <iceman@iuse.se>
Sat, 30 Dec 2017 14:23:14 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Sat, 30 Dec 2017 14:23:14 +0000 (15:23 +0100)
fix #532. looks at length of parameters.

1  2 
client/cmdhfmf.c

diff --combined client/cmdhfmf.c
index 5ebf814498a1f18ff272051986fcad131969fe63,cca4da88bdd04ed0ace3d044efaceebba70da8a1..c471fdf73186f5b50d54193a45ff4f9e4b0175a3
@@@ -987,6 -987,7 +987,7 @@@ int CmdHF14AMfChk(const char *Cmd
        int i, res;\r
        int     keycnt = 0;\r
        char ctmp       = 0x00;\r
+       int clen = 0;\r
        char ctmp3[3]   = {0x00};\r
        uint8_t blockNo = 0;\r
        uint8_t SectorsCnt = 0;\r
                blockNo = param_get8(Cmd, 0);\r
  \r
        ctmp = param_getchar(Cmd, 1);\r
-       switch (ctmp) {\r
-       case 'a': case 'A':\r
-               keyType = 0;\r
-               break;\r
-       case 'b': case 'B':\r
-               keyType = 1;\r
-               break;\r
-       case '?':\r
-               keyType = 2;\r
-               break;\r
-       default:\r
-               PrintAndLog("Key type must be A , B or ?");\r
-               free(keyBlock);\r
-               return 1;\r
-       };\r
+       clen = param_getlength(Cmd, 1);\r
+       if (clen == 1) {\r
+               switch (ctmp) {\r
+               case 'a': case 'A':\r
+                       keyType = 0;\r
+                       break;\r
+               case 'b': case 'B':\r
+                       keyType = 1;\r
+                       break;\r
+               case '?':\r
+                       keyType = 2;\r
+                       break;\r
+               default:\r
+                       PrintAndLog("Key type must be A , B or ?");\r
+                       free(keyBlock);\r
+                       return 1;\r
+               };\r
+       }\r
  \r
        // transfer to emulator & create dump file\r
        ctmp = param_getchar(Cmd, 2);\r
-       if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
-       if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;\r
+       clen = param_getlength(Cmd, 2);\r
+       if (clen == 1 && (ctmp == 't' || ctmp == 'T')) transferToEml = 1;\r
+       if (clen == 1 && (ctmp == 'd' || ctmp == 'D')) createDumpFile = 1;\r
        \r
        param3InUse = transferToEml | createDumpFile;\r
        \r
        timeout14a = 500; // fast by default\r
        // double parameters - ts, ds\r
-       int clen = param_getlength(Cmd, 2);\r
+       clen = param_getlength(Cmd, 2);\r
        if (clen == 2 || clen == 3){\r
                param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3));\r
                ctmp = ctmp3[1];\r
  \r
                                        if( buf[0]=='#' ) continue;     //The line start with # is comment, skip\r
  \r
 -                                      if (!isxdigit(buf[0])){\r
 +                                      if (!isxdigit((unsigned char)buf[0])){\r
                                                PrintAndLog("File content error. '%s' must include 12 HEX symbols",buf);\r
                                                continue;\r
                                        }\r
Impressum, Datenschutz