]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
BUGS: Coverty Scan, fixes some memory bugs
[proxmark3-svn] / client / cmdhfmf.c
index d9f3e6fdbac84a26a8c743ca573ad0d9c7551427..a4986f6bf28ffe591ea568eeaf73882b35df5037 100644 (file)
@@ -434,7 +434,7 @@ int CmdHF14AMfRestore(const char *Cmd)
 {\r
        uint8_t sectorNo,blockNo;\r
        uint8_t keyType = 0;\r
-       uint8_t key[6] = {0xFF};\r
+       uint8_t key[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};\r
        uint8_t bldata[16] = {0x00};\r
        uint8_t keyA[40][6];\r
        uint8_t keyB[40][6];\r
@@ -547,13 +547,15 @@ int CmdHF14AMfNested(const char *Cmd)
        uint8_t trgKeyType = 0;\r
        uint8_t SectorsCnt = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
-       uint8_t keyBlock[13*6];\r
+       uint8_t keyBlock[14*6];\r
        uint64_t key64 = 0;\r
        bool transferToEml = false;\r
+       \r
        bool createDumpFile = false;\r
        FILE *fkeys;\r
        uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
        uint8_t tempkey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
+       \r
        char cmdp, ctmp;\r
 \r
        if (strlen(Cmd)<3) {\r
@@ -682,6 +684,9 @@ int CmdHF14AMfNested(const char *Cmd)
                                        e_sector[i].Key[j] = key64;\r
                                        e_sector[i].foundKey[j] = 1;\r
                                }\r
+                       }\r
+               }\r
+               \r
                // nested sectors\r
                iterations = 0;\r
                PrintAndLog("nested...");\r
@@ -776,8 +781,8 @@ int CmdHF14AMfChk(const char *Cmd)
                PrintAndLog("Usage:  hf mf chk <block number>|<*card memory> <key type (A/B/?)> [t|d] [<key (12 hex symbols)>] [<dic (*.dic)>]");\r
                PrintAndLog("          * - all sectors");\r
                PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, <other> - 1K");\r
-               PrintAndLog("d - write keys to binary file\n");\r
-               PrintAndLog("t - write keys to emulator memory");\r
+               PrintAndLog("d - write keys to binary file");\r
+               PrintAndLog("t - write keys to emulator memory\n");\r
                PrintAndLog("      sample: hf mf chk 0 A 1234567890ab keys.dic");\r
                PrintAndLog("              hf mf chk *1 ? t");\r
                PrintAndLog("              hf mf chk *1 ? d");\r
@@ -1018,7 +1023,6 @@ int CmdHF14AMf1kSim(const char *Cmd)
                PrintAndLog("           x    (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)");\r
                PrintAndLog("");\r
                PrintAndLog("           sample: hf mf sim u 0a0a0a0a ");\r
-               PrintAndLog("                 : hf mf sim u 0a0a0a0a i x");\r
                return 0;\r
        }\r
        uint8_t pnr = 0;\r
@@ -1307,7 +1311,7 @@ int CmdHF14AMfESave(const char *Cmd)
                for (j = 0; j < 7; j++, fnameptr += 2)\r
                        sprintf(fnameptr, "%02X", buf[j]); \r
        } else {\r
-               fnameptr += len;\r
+               fnameptr += len-4;\r
        }\r
 \r
        // add file extension\r
@@ -1498,13 +1502,13 @@ int CmdHF14AMfCSetBlk(const char *Cmd)
        uint8_t memBlock[16] = {0x00};\r
        uint8_t blockNo = 0;\r
        bool wipeCard = FALSE;\r
-       int res = 0;    \r
+       int res;\r
 \r
        if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
                PrintAndLog("Usage:  hf mf csetblk <block number> <block data (32 hex symbols)> [w]");\r
                PrintAndLog("sample:  hf mf csetblk 1 01020304050607080910111213141516");\r
                PrintAndLog("Set block data for magic Chinese card (only works with such cards)");\r
-               PrintAndLog("If you also want to wipe the card then add 'w' at the end of the command line.");\r
+               PrintAndLog("If you also want wipe the card then add 'w' at the end of the command line");\r
                return 0;\r
        }       \r
 \r
@@ -1517,14 +1521,13 @@ int CmdHF14AMfCSetBlk(const char *Cmd)
 \r
        char ctmp = param_getchar(Cmd, 2);\r
        wipeCard = (ctmp == 'w' || ctmp == 'W');\r
-\r
        PrintAndLog("--block number:%2d data:%s", blockNo, sprint_hex(memBlock, 16));\r
 \r
        res = mfCSetBlock(blockNo, memBlock, NULL, wipeCard, CSETBLOCK_SINGLE_OPER);\r
        if (res) {\r
                PrintAndLog("Can't write block. error=%d", res);\r
                return 1;\r
-       }       \r
+       }\r
        return 0;\r
 }\r
 \r
@@ -1572,7 +1575,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
                if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
 \r
                memcpy(filename, Cmd, len);\r
-               fnameptr += len;\r
+               fnameptr += len-4;\r
 \r
                sprintf(fnameptr, ".eml"); \r
        \r
Impressum, Datenschutz