]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/iso14443a.c
FIXED: Merged all Holimans code-review issues which should fix a lot of memoryleaks.
[proxmark3-svn] / armsrc / iso14443a.c
index 0cd9053b4029740e4b9b17587c32f2424c62f58e..6fe83c6e672cede74bad42d286f1e8fccf0f1b4a 100644 (file)
@@ -1205,13 +1205,6 @@ static void TransmitFor14443a(const uint8_t *cmd, int len, uint32_t *timing)
        // clear TXRDY
        AT91C_BASE_SSC->SSC_THR = SEC_Y;
 
-       // for(uint16_t c = 0; c < 10;) {       // standard delay for each transfer (allow tag to be ready after last transmission)
-               // if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
-                       // AT91C_BASE_SSC->SSC_THR = SEC_Y;     
-                       // c++;
-               // }
-       // }
-
        uint16_t c = 0;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
@@ -1223,8 +1216,7 @@ static void TransmitFor14443a(const uint8_t *cmd, int len, uint32_t *timing)
                }
        }
        
-       NextTransferTime = MAX(NextTransferTime, LastTimeProxToAirStart + REQUEST_GUARD_TIME);
-       
+       NextTransferTime = MAX(NextTransferTime, LastTimeProxToAirStart + REQUEST_GUARD_TIME);  
 }
 
 
@@ -1615,13 +1607,6 @@ int ReaderReceive(uint8_t* receivedAnswer)
        return ReaderReceiveOffset(receivedAnswer, 0);
 }
 
-int ReaderReceiveDesfiresAuthTiming(uint8_t *receivedAnswer, uint32_t *elapsedTime)
-{
-       int len =  ReaderReceiveOffset(receivedAnswer, 0);
-       *elapsedTime =  (Demod.endTime*16 - DELAY_AIR2ARM_AS_READER) -  (Demod.startTime*16 - DELAY_AIR2ARM_AS_READER);
-       return len;
-}
-
 int ReaderReceivePar(uint8_t *receivedAnswer, uint32_t *parptr)
 {
        if (!GetIso14443aAnswerFromTag(receivedAnswer,0,160)) return FALSE;
@@ -1732,7 +1717,13 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
     if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
       // Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
       // http://www.nxp.com/documents/application_note/AN10927.pdf
-      memcpy(uid_resp, uid_resp + 1, 3);
+      // This was earlier:
+         //memcpy(uid_resp, uid_resp + 1, 3);
+         // But memcpy should not be used for overlapping arrays,
+         // and memmove appears to not be available in the arm build.
+         // So this has been replaced with a for-loop:
+         for(int xx = 0; xx < 3; xx++) 
+            uid_resp[xx] = uid_resp[xx+1];
       uid_resp_len = 3;
     }
 
@@ -1856,7 +1847,7 @@ void ReaderIso14443a(UsbCommand *c)
        }
 
        if(param & ISO14A_SET_TIMEOUT) {
-               iso14a_timeout = c->arg[2];
+               iso14a_set_timeout(c->arg[2]);
        }
 
        if(param & ISO14A_APDU) {
@@ -1943,7 +1934,8 @@ void ReaderMifare(bool first_try)
        uint8_t uid[10];
        uint32_t cuid;
 
-       uint32_t nt, previous_nt;
+       uint32_t nt = 0;
+       uint32_t previous_nt = 0;
        static uint32_t nt_attacked = 0;
        byte_t par_list[8] = {0,0,0,0,0,0,0,0};
        byte_t ks_list[8] = {0,0,0,0,0,0,0,0};
Impressum, Datenschutz