]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifarecmd.c
fix mfu dump getbigbuffer bug
[proxmark3-svn] / armsrc / mifarecmd.c
index 23652070ee0911cf54929bd550ad810cd03f055f..8355cd1946172da7c7cdf272938179bc95fef66a 100644 (file)
@@ -250,17 +250,26 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
 \r
 void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)\r
 {\r
+       // free eventually allocated BigBuf memory\r
+       BigBuf_free();\r
+       // clear trace\r
+       clear_trace();\r
+\r
        // params\r
        uint8_t blockNo = arg0;\r
        uint16_t blocks = arg1;\r
        bool useKey = (arg2 == 1); //UL_C\r
        bool usePwd = (arg2 == 2); //UL_EV1/NTAG\r
        uint32_t countblocks = 0;\r
-       uint8_t *dataout = BigBuf_get_addr();\r
+       uint8_t *dataout = BigBuf_malloc(CARD_MEMORY_SIZE);\r
+       if (dataout == NULL){\r
+               Dbprintf("out of memory");\r
+               OnError(1);\r
+               return;\r
+       }\r
 \r
        LEDsoff();\r
        LED_A_ON();\r
-       clear_trace();\r
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
 \r
        int len = iso14443a_select_card(NULL, NULL, NULL);\r
@@ -294,7 +303,7 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
        }\r
 \r
        for (int i = 0; i < blocks; i++){\r
-               if ((i*4) + 4 > BigBuf_get_traceLen()) {\r
+               if ((i*4) + 4 > CARD_MEMORY_SIZE) {\r
                        Dbprintf("Data exceeds buffer!!");\r
                        break;\r
                }\r
@@ -326,7 +335,7 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
        if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Blocks read %d", countblocks);\r
 \r
        countblocks *= 4;\r
-       cmd_send(CMD_ACK, 1, countblocks, countblocks, 0, 0);\r
+       cmd_send(CMD_ACK, 1, countblocks, BigBuf_max_traceLen(), 0, 0);\r
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
        LEDsoff();\r
 }\r
Impressum, Datenschutz