X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/9d87eb66500080f76d81b8d453f3f5340717c001..refs/pull/111/head:/armsrc/mifarecmd.c?ds=inline diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 23652070..8355cd19 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -250,17 +250,26 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain) { + // free eventually allocated BigBuf memory + BigBuf_free(); + // clear trace + clear_trace(); + // params uint8_t blockNo = arg0; uint16_t blocks = arg1; bool useKey = (arg2 == 1); //UL_C bool usePwd = (arg2 == 2); //UL_EV1/NTAG uint32_t countblocks = 0; - uint8_t *dataout = BigBuf_get_addr(); + uint8_t *dataout = BigBuf_malloc(CARD_MEMORY_SIZE); + if (dataout == NULL){ + Dbprintf("out of memory"); + OnError(1); + return; + } LEDsoff(); LED_A_ON(); - clear_trace(); iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); int len = iso14443a_select_card(NULL, NULL, NULL); @@ -294,7 +303,7 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain) } for (int i = 0; i < blocks; i++){ - if ((i*4) + 4 > BigBuf_get_traceLen()) { + if ((i*4) + 4 > CARD_MEMORY_SIZE) { Dbprintf("Data exceeds buffer!!"); break; } @@ -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); countblocks *= 4; - cmd_send(CMD_ACK, 1, countblocks, countblocks, 0, 0); + cmd_send(CMD_ACK, 1, countblocks, BigBuf_max_traceLen(), 0, 0); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); }