]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Code cleanup (#616)
authorpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 13 Jun 2018 06:13:20 +0000 (08:13 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Jun 2018 06:13:20 +0000 (08:13 +0200)
* coverity fixes (including a real bug in cmdhftopaz.c)
* Typo fix
* replace TRUE/FALSE by stdbool true/false

30 files changed:
armsrc/appmain.c
armsrc/hitag2.c
armsrc/hitagS.c
armsrc/iclass.c
armsrc/iso14443b.c
armsrc/iso15693.c
armsrc/lfops.c
armsrc/mifarecmd.c
armsrc/mifaresniff.c
armsrc/printf.c
client/cmdhf.c
client/cmdhf14a.c
client/cmdhfepa.c
client/cmdhflist.c
client/cmdhfmf.c
client/cmdhfmfhard.c
client/cmdhfmfu.c
client/cmdhftopaz.c
client/cmdlfhitag.c
client/cmdlfindala.c
client/emv/crypto_polarssl.c
client/flash.c
client/fpga_compress.c
client/mifarehost.c
client/proxgui.cpp
client/proxguiqt.h
client/scripting.c
client/util_posix.c
include/proxmark3.h
tools/mfkey/mfkey32.c

index 679a533ab3a5fbb826a6ba1f5ca87fea95836e85..e8581216522e189e8da3ab5880275f1c3c0ad208 100644 (file)
@@ -394,8 +394,8 @@ void StandAloneMode14a()
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        int selected = 0;
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        int selected = 0;
-       int playing = 0, iGotoRecord = 0, iGotoClone = 0;
-       int cardRead[OPTS] = {0};
+       bool playing = false, GotoRecord = false, GotoClone = false;
+       bool cardRead[OPTS] = {false};
        uint8_t readUID[10] = {0};
        uint32_t uid_1st[OPTS]={0};
        uint32_t uid_2nd[OPTS]={0};
        uint8_t readUID[10] = {0};
        uint32_t uid_1st[OPTS]={0};
        uint32_t uid_2nd[OPTS]={0};
@@ -411,9 +411,9 @@ void StandAloneMode14a()
                WDT_HIT();
                SpinDelay(300);
 
                WDT_HIT();
                SpinDelay(300);
 
-               if (iGotoRecord == 1 || cardRead[selected] == 0)
+               if (GotoRecord || !cardRead[selected])
                {
                {
-                       iGotoRecord = 0;
+                       GotoRecord = false;
                        LEDsoff();
                        LED(selected + 1, 0);
                        LED(LED_RED2, 0);
                        LEDsoff();
                        LED(selected + 1, 0);
                        LED(LED_RED2, 0);
@@ -438,7 +438,7 @@ void StandAloneMode14a()
                                        else if (cardRead[(selected+1)%OPTS]) {
                                                Dbprintf("Button press detected but no card in bank[%d] so playing from bank[%d]", selected, (selected+1)%OPTS);
                                                selected = (selected+1)%OPTS;
                                        else if (cardRead[(selected+1)%OPTS]) {
                                                Dbprintf("Button press detected but no card in bank[%d] so playing from bank[%d]", selected, (selected+1)%OPTS);
                                                selected = (selected+1)%OPTS;
-                                               break; // playing = 1;
+                                               break;
                                        }
                                        else {
                                                Dbprintf("Button press detected but no stored tag to play. (Ignoring button)");
                                        }
                                        else {
                                                Dbprintf("Button press detected but no stored tag to play. (Ignoring button)");
@@ -488,14 +488,14 @@ void StandAloneMode14a()
                        LED(selected + 1, 0);
 
                        // Next state is replay:
                        LED(selected + 1, 0);
 
                        // Next state is replay:
-                       playing = 1;
+                       playing = true;
 
 
-                       cardRead[selected] = 1;
+                       cardRead[selected] = true;
                }
                /* MF Classic UID clone */
                }
                /* MF Classic UID clone */
-               else if (iGotoClone==1)
+               else if (GotoClone)
                {
                {
-                       iGotoClone=0;
+                       GotoClone=false;
                        LEDsoff();
                        LED(selected + 1, 0);
                        LED(LED_ORANGE, 250);
                        LEDsoff();
                        LED(selected + 1, 0);
                        LED(LED_ORANGE, 250);
@@ -546,7 +546,7 @@ void StandAloneMode14a()
                        MifareCGetBlock(0x3F, 1, 0, oldBlock0);
                        if (oldBlock0[0] == 0 && oldBlock0[0] == oldBlock0[1]  && oldBlock0[1] == oldBlock0[2] && oldBlock0[2] == oldBlock0[3]) {
                                Dbprintf("No changeable tag detected. Returning to replay mode for bank[%d]", selected);
                        MifareCGetBlock(0x3F, 1, 0, oldBlock0);
                        if (oldBlock0[0] == 0 && oldBlock0[0] == oldBlock0[1]  && oldBlock0[1] == oldBlock0[2] && oldBlock0[2] == oldBlock0[3]) {
                                Dbprintf("No changeable tag detected. Returning to replay mode for bank[%d]", selected);
-                               playing = 1;
+                               playing = true;
                        }
                        else {
                                Dbprintf("UID from target tag: %02X%02X%02X%02X", oldBlock0[0],oldBlock0[1],oldBlock0[2],oldBlock0[3]);
                        }
                        else {
                                Dbprintf("UID from target tag: %02X%02X%02X%02X", oldBlock0[0],oldBlock0[1],oldBlock0[2],oldBlock0[3]);
@@ -564,14 +564,14 @@ void StandAloneMode14a()
                                if (memcmp(testBlock0,newBlock0,16)==0)
                                {
                                        DbpString("Cloned successfull!");
                                if (memcmp(testBlock0,newBlock0,16)==0)
                                {
                                        DbpString("Cloned successfull!");
-                                       cardRead[selected] = 0; // Only if the card was cloned successfully should we clear it
-                                       playing = 0;
-                                       iGotoRecord = 1;
+                                       cardRead[selected] = false; // Only if the card was cloned successfully should we clear it
+                                       playing = false;
+                                       GotoRecord = true;
                                        selected = (selected+1) % OPTS;
                                }
                                else {
                                        Dbprintf("Clone failed. Back to replay mode on bank[%d]", selected);
                                        selected = (selected+1) % OPTS;
                                }
                                else {
                                        Dbprintf("Clone failed. Back to replay mode on bank[%d]", selected);
-                                       playing = 1;
+                                       playing = true;
                                }
                        }
                        LEDsoff();
                                }
                        }
                        LEDsoff();
@@ -579,61 +579,55 @@ void StandAloneMode14a()
 
                }
                // Change where to record (or begin playing)
 
                }
                // Change where to record (or begin playing)
-               else if (playing==1) // button_pressed == BUTTON_SINGLE_CLICK && cardRead[selected])
+               else if (playing) // button_pressed == BUTTON_SINGLE_CLICK && cardRead[selected])
                {
                        LEDsoff();
                        LED(selected + 1, 0);
 
                        // Begin transmitting
                {
                        LEDsoff();
                        LED(selected + 1, 0);
 
                        // Begin transmitting
-                       if (playing)
-                       {
-                               LED(LED_GREEN, 0);
-                               DbpString("Playing");
-                               for ( ; ; ) {
-                                       WDT_HIT();
-                                       int button_action = BUTTON_HELD(1000);
-                                       if (button_action == 0) { // No button action, proceed with sim
-                                               uint8_t data[512] = {0}; // in case there is a read command received we shouldn't break
-                                               Dbprintf("Simulating ISO14443a tag with uid[0]: %08x, uid[1]: %08x [Bank: %u]", uid_1st[selected],uid_2nd[selected],selected);
-                                               if (hi14a_card[selected].sak == 8 && hi14a_card[selected].atqa[0] == 4 && hi14a_card[selected].atqa[1] == 0) {
-                                                       DbpString("Mifare Classic");
-                                                       SimulateIso14443aTag(1,uid_1st[selected], uid_2nd[selected], data); // Mifare Classic
-                                               }
-                                               else if (hi14a_card[selected].sak == 0 && hi14a_card[selected].atqa[0] == 0x44 && hi14a_card[selected].atqa[1] == 0) {
-                                                       DbpString("Mifare Ultralight");
-                                                       SimulateIso14443aTag(2,uid_1st[selected],uid_2nd[selected],data); // Mifare Ultralight
-                                               }
-                                               else if (hi14a_card[selected].sak == 20 && hi14a_card[selected].atqa[0] == 0x44 && hi14a_card[selected].atqa[1] == 3) {
-                                                       DbpString("Mifare DESFire");
-                                                       SimulateIso14443aTag(3,uid_1st[selected],uid_2nd[selected],data); // Mifare DESFire
-                                               }
-                                               else {
-                                                       Dbprintf("Unrecognized tag type -- defaulting to Mifare Classic emulation");
-                                                       SimulateIso14443aTag(1,uid_1st[selected], uid_2nd[selected], data);
-                                               }
+                       LED(LED_GREEN, 0);
+                       DbpString("Playing");
+                       for ( ; ; ) {
+                               WDT_HIT();
+                               int button_action = BUTTON_HELD(1000);
+                               if (button_action == 0) { // No button action, proceed with sim
+                                       uint8_t data[512] = {0}; // in case there is a read command received we shouldn't break
+                                       Dbprintf("Simulating ISO14443a tag with uid[0]: %08x, uid[1]: %08x [Bank: %u]", uid_1st[selected],uid_2nd[selected],selected);
+                                       if (hi14a_card[selected].sak == 8 && hi14a_card[selected].atqa[0] == 4 && hi14a_card[selected].atqa[1] == 0) {
+                                               DbpString("Mifare Classic");
+                                               SimulateIso14443aTag(1,uid_1st[selected], uid_2nd[selected], data); // Mifare Classic
                                        }
                                        }
-                                       else if (button_action == BUTTON_SINGLE_CLICK) {
-                                               selected = (selected + 1) % OPTS;
-                                               Dbprintf("Done playing. Switching to record mode on bank %d",selected);
-                                               iGotoRecord = 1;
-                                               break;
+                                       else if (hi14a_card[selected].sak == 0 && hi14a_card[selected].atqa[0] == 0x44 && hi14a_card[selected].atqa[1] == 0) {
+                                               DbpString("Mifare Ultralight");
+                                               SimulateIso14443aTag(2,uid_1st[selected],uid_2nd[selected],data); // Mifare Ultralight
                                        }
                                        }
-                                       else if (button_action == BUTTON_HOLD) {
-                                               Dbprintf("Playtime over. Begin cloning...");
-                                               iGotoClone = 1;
-                                               break;
+                                       else if (hi14a_card[selected].sak == 20 && hi14a_card[selected].atqa[0] == 0x44 && hi14a_card[selected].atqa[1] == 3) {
+                                               DbpString("Mifare DESFire");
+                                               SimulateIso14443aTag(3,uid_1st[selected],uid_2nd[selected],data); // Mifare DESFire
+                                       }
+                                       else {
+                                               Dbprintf("Unrecognized tag type -- defaulting to Mifare Classic emulation");
+                                               SimulateIso14443aTag(1,uid_1st[selected], uid_2nd[selected], data);
                                        }
                                        }
-                                       WDT_HIT();
                                }
                                }
-
-                               /* We pressed a button so ignore it here with a delay */
-                               SpinDelay(300);
-                               LEDsoff();
-                               LED(selected + 1, 0);
+                               else if (button_action == BUTTON_SINGLE_CLICK) {
+                                       selected = (selected + 1) % OPTS;
+                                       Dbprintf("Done playing. Switching to record mode on bank %d",selected);
+                                       GotoRecord = true;
+                                       break;
+                               }
+                               else if (button_action == BUTTON_HOLD) {
+                                       Dbprintf("Playtime over. Begin cloning...");
+                                       GotoClone = true;
+                                       break;
+                               }
+                               WDT_HIT();
                        }
                        }
-                       else
-                               while(BUTTON_PRESS())
-                                       WDT_HIT();
+
+                       /* We pressed a button so ignore it here with a delay */
+                       SpinDelay(300);
+                       LEDsoff();
+                       LED(selected + 1, 0);
                }
        }
 }
                }
        }
 }
index aec0186068ff56fb58b1c90e09807f82129f762d..8e690a7b556d2cf11be72baff5202bf1afca2569 100644 (file)
@@ -813,13 +813,13 @@ void SnoopHitag(uint32_t type) {
        int lastbit;
        bool bSkip;
        int tag_sof;
        int lastbit;
        bool bSkip;
        int tag_sof;
-       byte_t rx[HITAG_FRAME_LEN];
+       byte_t rx[HITAG_FRAME_LEN] = {0};
        size_t rxlen=0;
        
        FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
 
        // Clean up trace and prepare it for storing frames
        size_t rxlen=0;
        
        FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
 
        // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
        
        auth_table_len = 0;
        clear_trace();
        
        auth_table_len = 0;
@@ -1032,7 +1032,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) {
        FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
 
        // Clean up trace and prepare it for storing frames
        FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
 
        // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        auth_table_len = 0;
        clear_trace();
 
        auth_table_len = 0;
@@ -1225,7 +1225,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
        bSuccessful = false;
   
        // Clean up trace and prepare it for storing frames
        bSuccessful = false;
   
        // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        //DbpString("Starting Hitag reader family");
        clear_trace();
 
        //DbpString("Starting Hitag reader family");
@@ -1548,7 +1548,7 @@ void WriterHitag(hitag_function htf, hitag_data* htd, int page) {
        bSuccessful = false;
   
        // Clean up trace and prepare it for storing frames
        bSuccessful = false;
   
        // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        //DbpString("Starting Hitag reader family");
        clear_trace();
 
        //DbpString("Starting Hitag reader family");
index 7d36d84b988283e866ea28ccfe81350042713c91..f6ba0c6bf8186060e7c724d503b01f497fe9feef 100644 (file)
@@ -210,7 +210,7 @@ static void hitag_send_bit(int bit) {
                                ;
                        LOW(GPIO_SSC_DOUT);
                        while (AT91C_BASE_TC0->TC_CV < T0 * 32)
                                ;
                        LOW(GPIO_SSC_DOUT);
                        while (AT91C_BASE_TC0->TC_CV < T0 * 32)
-                               ;;
+                               ;
                }
                LED_A_OFF();
                break;
                }
                LED_A_OFF();
                break;
@@ -945,7 +945,6 @@ void SimulateHitagSTag(bool tag_mem_supplied, byte_t* data) {
        int i, j;
        byte_t rx[HITAG_FRAME_LEN];
        size_t rxlen = 0;
        int i, j;
        byte_t rx[HITAG_FRAME_LEN];
        size_t rxlen = 0;
-//bool bQuitTraceFull = false;
        bQuiet = false;
        byte_t txbuf[HITAG_FRAME_LEN];
        byte_t* tx = txbuf;
        bQuiet = false;
        byte_t txbuf[HITAG_FRAME_LEN];
        byte_t* tx = txbuf;
@@ -953,7 +952,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, byte_t* data) {
        BigBuf_free();
 
 // Clean up trace and prepare it for storing frames
        BigBuf_free();
 
 // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        DbpString("Starting HitagS simulation");
        clear_trace();
 
        DbpString("Starting HitagS simulation");
@@ -1216,7 +1215,7 @@ void ReadHitagS(hitag_function htf, hitag_data* htd) {
        bSuccessful = false;
 
 // Clean up trace and prepare it for storing frames
        bSuccessful = false;
 
 // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        bQuiet = false;
        clear_trace();
 
        bQuiet = false;
@@ -1560,7 +1559,7 @@ void WritePageHitagS(hitag_function htf, hitag_data* htd,int page_) {
        tag.tstate = NO_OP;
 
 // Clean up trace and prepare it for storing frames
        tag.tstate = NO_OP;
 
 // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        bQuiet = false;
        clear_trace();
 
        bQuiet = false;
@@ -1847,7 +1846,7 @@ void check_challenges(bool file_given, byte_t* data) {
        bSuccessful = false;
 
 // Clean up trace and prepare it for storing frames
        bSuccessful = false;
 
 // Clean up trace and prepare it for storing frames
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
 
        bQuiet = false;
        clear_trace();
 
        bQuiet = false;
index f9aedc9577f17a89c36b9b56d82459b6e8c93f75..c587f8ea98b9708862b80c6430a4e67b4caa6ef5 100644 (file)
@@ -91,7 +91,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
 
        if(!Uart.bitBuffer) {
                Uart.bitBuffer = bit ^ 0xFF0;
 
        if(!Uart.bitBuffer) {
                Uart.bitBuffer = bit ^ 0xFF0;
-               return FALSE;
+               return false;
        }
        else {
                Uart.bitBuffer <<= 4;
        }
        else {
                Uart.bitBuffer <<= 4;
@@ -102,7 +102,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
                Uart.output[Uart.byteCnt] = Uart.bitBuffer & 0xFF;
                Uart.byteCnt++;
                Uart.swapper = 0;
                Uart.output[Uart.byteCnt] = Uart.bitBuffer & 0xFF;
                Uart.byteCnt++;
                Uart.swapper = 0;
-               if(Uart.byteCnt > 15) { return TRUE; }
+               if(Uart.byteCnt > 15) { return true; }
        }
        else {
                Uart.swapper = 1;
        }
        else {
                Uart.swapper = 1;
@@ -139,12 +139,12 @@ static RAMFUNC int OutOfNDecoding(int bit)
                                        Uart.highCnt = 0;
                                        if(Uart.byteCnt == 0) {
                                                // Its not straightforward to show single EOFs
                                        Uart.highCnt = 0;
                                        if(Uart.byteCnt == 0) {
                                                // Its not straightforward to show single EOFs
-                                               // So just leave it and do not return TRUE
+                                               // So just leave it and do not return true
                                                Uart.output[0] = 0xf0;
                                                Uart.byteCnt++;
                                        }
                                        else {
                                                Uart.output[0] = 0xf0;
                                                Uart.byteCnt++;
                                        }
                                        else {
-                                               return TRUE;
+                                               return true;
                                        }
                                }
                                else if(Uart.state != STATE_START_OF_COMMUNICATION) {
                                        }
                                }
                                else if(Uart.state != STATE_START_OF_COMMUNICATION) {
@@ -263,7 +263,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
                                Uart.byteCnt++;
                                Uart.output[Uart.byteCnt] = 0xAA;
                                Uart.byteCnt++;
                                Uart.byteCnt++;
                                Uart.output[Uart.byteCnt] = 0xAA;
                                Uart.byteCnt++;
-                               return TRUE;
+                               return true;
                        }*/
                }
 
                        }*/
                }
 
@@ -318,7 +318,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
                }
        }
 
                }
        }
 
-    return FALSE;
+    return false;
 }
 
 //=============================================================================
 }
 
 //=============================================================================
@@ -371,7 +371,7 @@ static RAMFUNC int ManchesterDecoding(int v)
 
        if(Demod.buff < 3) {
                Demod.buff++;
 
        if(Demod.buff < 3) {
                Demod.buff++;
-               return FALSE;
+               return false;
        }
 
        if(Demod.state==DEMOD_UNSYNCD) {
        }
 
        if(Demod.state==DEMOD_UNSYNCD) {
@@ -473,7 +473,7 @@ static RAMFUNC int ManchesterDecoding(int v)
                                        Demod.len++;
                                        Demod.state = DEMOD_UNSYNCD;
 //                                     error = 0x0f;
                                        Demod.len++;
                                        Demod.state = DEMOD_UNSYNCD;
 //                                     error = 0x0f;
-                                       return TRUE;
+                                       return true;
                                }
                                else {
                                        Demod.state = DEMOD_ERROR_WAIT;
                                }
                                else {
                                        Demod.state = DEMOD_ERROR_WAIT;
@@ -557,7 +557,7 @@ static RAMFUNC int ManchesterDecoding(int v)
                                                }
 
                                                Demod.state = DEMOD_UNSYNCD;
                                                }
 
                                                Demod.state = DEMOD_UNSYNCD;
-                                               return TRUE;
+                                               return true;
                                        }
                                        else {
                                                Demod.output[Demod.len] = 0xad;
                                        }
                                        else {
                                                Demod.output[Demod.len] = 0xad;
@@ -612,14 +612,14 @@ static RAMFUNC int ManchesterDecoding(int v)
                                Demod.len++;
                                Demod.output[Demod.len] = 0xBB;
                                Demod.len++;
                                Demod.len++;
                                Demod.output[Demod.len] = 0xBB;
                                Demod.len++;
-                               return TRUE;
+                               return true;
                        }
 
                }
 
        } // end (state != UNSYNCED)
 
                        }
 
                }
 
        } // end (state != UNSYNCED)
 
-    return FALSE;
+    return false;
 }
 
 //=============================================================================
 }
 
 //=============================================================================
@@ -639,7 +639,7 @@ void RAMFUNC SnoopIClass(void)
     // We won't start recording the frames that we acquire until we trigger;
     // a good trigger condition to get started is probably when we see a
     // response from the tag.
     // We won't start recording the frames that we acquire until we trigger;
     // a good trigger condition to get started is probably when we see a
     // response from the tag.
-    //int triggered = FALSE; // FALSE to wait first for card
+    //int triggered = false; // false to wait first for card
 
     // The command (reader -> tag) that we're receiving.
        // The length of a received command will in most cases be no more than 18 bytes.
 
     // The command (reader -> tag) that we're receiving.
        // The length of a received command will in most cases be no more than 18 bytes.
@@ -656,9 +656,9 @@ void RAMFUNC SnoopIClass(void)
     // The DMA buffer, used to stream samples from the FPGA
     uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
  
     // The DMA buffer, used to stream samples from the FPGA
     uint8_t *dmaBuf = BigBuf_malloc(DMA_BUFFER_SIZE);
  
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
        clear_trace();
-    iso14a_set_trigger(FALSE);
+    iso14a_set_trigger(false);
 
        int lastRxCounter;
     uint8_t *upTo;
 
        int lastRxCounter;
     uint8_t *upTo;
@@ -749,12 +749,12 @@ void RAMFUNC SnoopIClass(void)
                        time_stop = (GetCountSspClk()-time_0) << 4;
                    LED_C_ON();
 
                        time_stop = (GetCountSspClk()-time_0) << 4;
                    LED_C_ON();
 
-                       //if(!LogTrace(Uart.output,Uart.byteCnt, rsamples, Uart.parityBits,TRUE)) break;
-                       //if(!LogTrace(NULL, 0, Uart.endTime*16 - DELAY_READER_AIR2ARM_AS_SNIFFER, 0, TRUE)) break;
+                       //if(!LogTrace(Uart.output,Uart.byteCnt, rsamples, Uart.parityBits,true)) break;
+                       //if(!LogTrace(NULL, 0, Uart.endTime*16 - DELAY_READER_AIR2ARM_AS_SNIFFER, 0, true)) break;
                        if(tracing)     {
                                uint8_t parity[MAX_PARITY_SIZE];
                                GetParity(Uart.output, Uart.byteCnt, parity);
                        if(tracing)     {
                                uint8_t parity[MAX_PARITY_SIZE];
                                GetParity(Uart.output, Uart.byteCnt, parity);
-                               LogTrace(Uart.output,Uart.byteCnt, time_start, time_stop, parity, TRUE);
+                               LogTrace(Uart.output,Uart.byteCnt, time_start, time_stop, parity, true);
                        }
 
 
                        }
 
 
@@ -782,7 +782,7 @@ void RAMFUNC SnoopIClass(void)
                        if(tracing)     {
                                uint8_t parity[MAX_PARITY_SIZE];
                                GetParity(Demod.output, Demod.len, parity);
                        if(tracing)     {
                                uint8_t parity[MAX_PARITY_SIZE];
                                GetParity(Demod.output, Demod.len, parity);
-                               LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, FALSE);
+                               LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, false);
                        }
 
                    // And ready to receive another response.
                        }
 
                    // And ready to receive another response.
@@ -830,7 +830,7 @@ void rotateCSN(uint8_t* originalCSN, uint8_t* rotatedCSN) {
 //-----------------------------------------------------------------------------
 // Wait for commands from reader
 // Stop when button is pressed
 //-----------------------------------------------------------------------------
 // Wait for commands from reader
 // Stop when button is pressed
-// Or return TRUE when command is captured
+// Or return true when command is captured
 //-----------------------------------------------------------------------------
 static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
 {
 //-----------------------------------------------------------------------------
 static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
 {
@@ -848,7 +848,7 @@ static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
     for(;;) {
         WDT_HIT();
 
     for(;;) {
         WDT_HIT();
 
-        if(BUTTON_PRESS()) return FALSE;
+        if(BUTTON_PRESS()) return false;
 
         if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
             AT91C_BASE_SSC->SSC_THR = 0x00;
 
         if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
             AT91C_BASE_SSC->SSC_THR = 0x00;
@@ -858,7 +858,7 @@ static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
 
                        if(OutOfNDecoding(b & 0x0f)) {
                                *len = Uart.byteCnt;
 
                        if(OutOfNDecoding(b & 0x0f)) {
                                *len = Uart.byteCnt;
-                               return TRUE;
+                               return true;
                        }
         }
     }
                        }
         }
     }
@@ -993,7 +993,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        // Enable and clear the trace
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        // Enable and clear the trace
-       set_tracing(TRUE);
+       set_tracing(true);
        clear_trace();
        //Use the emulator memory for SIM
        uint8_t *emulator = BigBuf_get_EM_addr();
        clear_trace();
        //Use the emulator memory for SIM
        uint8_t *emulator = BigBuf_get_EM_addr();
@@ -1325,11 +1325,11 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf)
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
                        GetParity(receivedCmd, len, parity);
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
                        GetParity(receivedCmd, len, parity);
-                       LogTrace(receivedCmd,len, (r2t_time-time_0)<< 4, (r2t_time-time_0) << 4, parity, TRUE);
+                       LogTrace(receivedCmd,len, (r2t_time-time_0)<< 4, (r2t_time-time_0) << 4, parity, true);
 
                        if (trace_data != NULL) {
                                GetParity(trace_data, trace_data_size, parity);
 
                        if (trace_data != NULL) {
                                GetParity(trace_data, trace_data_size, parity);
-                               LogTrace(trace_data, trace_data_size, (t2r_time-time_0) << 4, (t2r_time-time_0) << 4, parity, FALSE);
+                               LogTrace(trace_data, trace_data_size, (t2r_time-time_0) << 4, (t2r_time-time_0) << 4, parity, false);
                        }
                        if(!tracing) {
                                DbpString("Trace full");
                        }
                        if(!tracing) {
                                DbpString("Trace full");
@@ -1420,7 +1420,7 @@ static void TransmitIClassCommand(const uint8_t *cmd, int len, int *samples, int
 
 
   uint8_t sendbyte;
 
 
   uint8_t sendbyte;
-  bool firstpart = TRUE;
+  bool firstpart = true;
   c = 0;
   for(;;) {
     if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
   c = 0;
   for(;;) {
     if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
@@ -1512,14 +1512,14 @@ void ReaderTransmitIClass(uint8_t* frame, int len)
        if (tracing) {
                uint8_t par[MAX_PARITY_SIZE];
                GetParity(frame, len, par);
        if (tracing) {
                uint8_t par[MAX_PARITY_SIZE];
                GetParity(frame, len, par);
-               LogTrace(frame, len, rsamples, rsamples, par, TRUE);
+               LogTrace(frame, len, rsamples, rsamples, par, true);
        }
 }
 
 //-----------------------------------------------------------------------------
 // Wait a certain time for tag response
        }
 }
 
 //-----------------------------------------------------------------------------
 // Wait a certain time for tag response
-//  If a response is captured return TRUE
-//  If it takes too long return FALSE
+//  If a response is captured return true
+//  If it takes too long return false
 //-----------------------------------------------------------------------------
 static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed) //uint8_t *buffer
 {
 //-----------------------------------------------------------------------------
 static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed) //uint8_t *buffer
 {
@@ -1538,27 +1538,27 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
        uint8_t b;
        if (elapsed) *elapsed = 0;
 
        uint8_t b;
        if (elapsed) *elapsed = 0;
 
-       bool skip = FALSE;
+       bool skip = false;
 
        c = 0;
        for(;;) {
                WDT_HIT();
 
 
        c = 0;
        for(;;) {
                WDT_HIT();
 
-               if(BUTTON_PRESS()) return FALSE;
+               if(BUTTON_PRESS()) return false;
 
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x00;  // To make use of exact timing of next command from reader!!
                        if (elapsed) (*elapsed)++;
                }
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
 
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x00;  // To make use of exact timing of next command from reader!!
                        if (elapsed) (*elapsed)++;
                }
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
-                       if(c < timeout) { c++; } else { return FALSE; }
+                       if(c < timeout) { c++; } else { return false; }
                        b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        skip = !skip;
                        if(skip) continue;
                
                        if(ManchesterDecoding(b & 0x0f)) {
                                *samples = c << 3;
                        b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        skip = !skip;
                        if(skip) continue;
                
                        if(ManchesterDecoding(b & 0x0f)) {
                                *samples = c << 3;
-                               return  TRUE;
+                               return  true;
                        }
                }
        }
                        }
                }
        }
@@ -1567,14 +1567,14 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
 int ReaderReceiveIClass(uint8_t* receivedAnswer)
 {
   int samples = 0;
 int ReaderReceiveIClass(uint8_t* receivedAnswer)
 {
   int samples = 0;
-  if (!GetIClassAnswer(receivedAnswer,160,&samples,0)) return FALSE;
+  if (!GetIClassAnswer(receivedAnswer,160,&samples,0)) return false;
   rsamples += samples;
   if (tracing) {
        uint8_t parity[MAX_PARITY_SIZE];
        GetParity(receivedAnswer, Demod.len, parity);
   rsamples += samples;
   if (tracing) {
        uint8_t parity[MAX_PARITY_SIZE];
        GetParity(receivedAnswer, Demod.len, parity);
-       LogTrace(receivedAnswer,Demod.len,rsamples,rsamples,parity,FALSE);
+       LogTrace(receivedAnswer,Demod.len,rsamples,rsamples,parity,false);
   }
   }
-  if(samples == 0) return FALSE;
+  if(samples == 0) return false;
   return Demod.len;
 }
 
   return Demod.len;
 }
 
@@ -1582,7 +1582,7 @@ void setupIclassReader()
 {
     FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
     // Reset trace buffer
 {
     FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
     // Reset trace buffer
-         set_tracing(TRUE);
+         set_tracing(true);
          clear_trace();
 
     // Setup SSC
          clear_trace();
 
     // Setup SSC
@@ -1822,7 +1822,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
        uint8_t resp[ICLASS_BUFFER_SIZE];
        
     setupIclassReader();
        uint8_t resp[ICLASS_BUFFER_SIZE];
        
     setupIclassReader();
-       set_tracing(TRUE);
+       set_tracing(true);
 
        while(!BUTTON_PRESS()) {
        
 
        while(!BUTTON_PRESS()) {
        
index 22227e74bec96651d5c2620dd37f4bea210f27d2..75769859392c725453b4ede60ae9a5b3a60a3797 100644 (file)
@@ -243,7 +243,7 @@ static RAMFUNC int Handle14443bUartBit(uint8_t bit)
                                        LED_A_OFF(); // Finished receiving
                                        Uart.state = STATE_UNSYNCD;
                                        if (Uart.byteCnt != 0) {
                                        LED_A_OFF(); // Finished receiving
                                        Uart.state = STATE_UNSYNCD;
                                        if (Uart.byteCnt != 0) {
-                                               return TRUE;
+                                               return true;
                                        }
                                } else {
                                        // this is an error
                                        }
                                } else {
                                        // this is an error
@@ -259,7 +259,7 @@ static RAMFUNC int Handle14443bUartBit(uint8_t bit)
                        break;
        }
 
                        break;
        }
 
-       return FALSE;
+       return false;
 }
 
 
 }
 
 
@@ -283,7 +283,7 @@ static void UartInit(uint8_t *data)
 // Receive a command (from the reader to us, where we are the simulated tag),
 // and store it in the given buffer, up to the given maximum length. Keeps
 // spinning, waiting for a well-framed command, until either we get one
 // Receive a command (from the reader to us, where we are the simulated tag),
 // and store it in the given buffer, up to the given maximum length. Keeps
 // spinning, waiting for a well-framed command, until either we get one
-// (returns TRUE) or someone presses the pushbutton on the board (FALSE).
+// (returns true) or someone presses the pushbutton on the board (false).
 //
 // Assume that we're called with the SSC (to the FPGA) and ADC path set
 // correctly.
 //
 // Assume that we're called with the SSC (to the FPGA) and ADC path set
 // correctly.
@@ -302,20 +302,20 @@ static int GetIso14443bCommandFromReader(uint8_t *received, uint16_t *len)
        for(;;) {
                WDT_HIT();
 
        for(;;) {
                WDT_HIT();
 
-               if(BUTTON_PRESS()) return FALSE;
+               if(BUTTON_PRESS()) return false;
 
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
                        uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        for(uint8_t mask = 0x80; mask != 0x00; mask >>= 1) {
                                if(Handle14443bUartBit(b & mask)) {
                                        *len = Uart.byteCnt;
 
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
                        uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        for(uint8_t mask = 0x80; mask != 0x00; mask >>= 1) {
                                if(Handle14443bUartBit(b & mask)) {
                                        *len = Uart.byteCnt;
-                                       return TRUE;
+                                       return true;
                                }
                        }
                }
        }
 
                                }
                        }
                }
        }
 
-       return FALSE;
+       return false;
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------
@@ -347,7 +347,7 @@ void SimulateIso14443bTag(void)
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        clear_trace();
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 
        clear_trace();
-       set_tracing(TRUE);
+       set_tracing(true);
 
        const uint8_t *resp;
        uint8_t *respCode;
 
        const uint8_t *resp;
        uint8_t *respCode;
@@ -387,7 +387,7 @@ void SimulateIso14443bTag(void)
 
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
 
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
-                       LogTrace(receivedCmd, len, 0, 0, parity, TRUE);
+                       LogTrace(receivedCmd, len, 0, 0, parity, true);
                }
 
                // Good, look at the command now.
                }
 
                // Good, look at the command now.
@@ -464,7 +464,7 @@ void SimulateIso14443bTag(void)
                // trace the response:
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
                // trace the response:
                if (tracing) {
                        uint8_t parity[MAX_PARITY_SIZE];
-                       LogTrace(resp, respLen, 0, 0, parity, FALSE);
+                       LogTrace(resp, respLen, 0, 0, parity, false);
                }
 
        }
                }
 
        }
@@ -702,7 +702,7 @@ static RAMFUNC int Handle14443bSamplesDemod(int ci, int cq)
                                                LED_C_OFF();
                                                if(s == 0x000) {
                                                        // This is EOF (start, stop and all data bits == '0'
                                                LED_C_OFF();
                                                if(s == 0x000) {
                                                        // This is EOF (start, stop and all data bits == '0'
-                                                       return TRUE;
+                                                       return true;
                                                }
                                        }
                                }
                                                }
                                        }
                                }
@@ -716,7 +716,7 @@ static RAMFUNC int Handle14443bSamplesDemod(int ci, int cq)
                        break;
        }
 
                        break;
        }
 
-       return FALSE;
+       return false;
 }
 
 
 }
 
 
@@ -739,12 +739,12 @@ static void DemodInit(uint8_t *data)
 
 /*
  *  Demodulate the samples we received from the tag, also log to tracebuffer
 
 /*
  *  Demodulate the samples we received from the tag, also log to tracebuffer
- *  quiet: set to 'TRUE' to disable debug output
+ *  quiet: set to 'true' to disable debug output
  */
 static void GetSamplesFor14443bDemod(int n, bool quiet)
 {
        int max = 0;
  */
 static void GetSamplesFor14443bDemod(int n, bool quiet)
 {
        int max = 0;
-       bool gotFrame = FALSE;
+       bool gotFrame = false;
        int lastRxCounter, ci, cq, samples = 0;
 
        // Allocate memory from BigBuf for some buffers
        int lastRxCounter, ci, cq, samples = 0;
 
        // Allocate memory from BigBuf for some buffers
@@ -792,7 +792,7 @@ static void GetSamplesFor14443bDemod(int n, bool quiet)
                        samples += 2;
 
                        if(Handle14443bSamplesDemod(ci, cq)) {
                        samples += 2;
 
                        if(Handle14443bSamplesDemod(ci, cq)) {
-                               gotFrame = TRUE;
+                               gotFrame = true;
                                break;
                        }
                }
                                break;
                        }
                }
@@ -808,7 +808,7 @@ static void GetSamplesFor14443bDemod(int n, bool quiet)
        //Tracing
        if (tracing && Demod.len > 0) {
                uint8_t parity[MAX_PARITY_SIZE];
        //Tracing
        if (tracing && Demod.len > 0) {
                uint8_t parity[MAX_PARITY_SIZE];
-               LogTrace(Demod.output, Demod.len, 0, 0, parity, FALSE);
+               LogTrace(Demod.output, Demod.len, 0, 0, parity, false);
        }
 }
 
        }
 }
 
@@ -929,7 +929,7 @@ static void CodeAndTransmit14443bAsReader(const uint8_t *cmd, int len)
        TransmitFor14443b();
        if (tracing) {
                uint8_t parity[MAX_PARITY_SIZE];
        TransmitFor14443b();
        if (tracing) {
                uint8_t parity[MAX_PARITY_SIZE];
-               LogTrace(cmd,len, 0, 0, parity, TRUE);
+               LogTrace(cmd,len, 0, 0, parity, true);
        }
 }
 
        }
 }
 
@@ -951,7 +951,7 @@ int iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *respo
        // send
        CodeAndTransmit14443bAsReader(message_frame, message_length + 4);
        // get response
        // send
        CodeAndTransmit14443bAsReader(message_frame, message_length + 4);
        // get response
-       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT*100, TRUE);
+       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT*100, true);
        if(Demod.len < 3)
        {
                return 0;
        if(Demod.len < 3)
        {
                return 0;
@@ -981,7 +981,7 @@ int iso14443b_select_card()
 
        // first, wake up the tag
        CodeAndTransmit14443bAsReader(wupb, sizeof(wupb));
 
        // first, wake up the tag
        CodeAndTransmit14443bAsReader(wupb, sizeof(wupb));
-       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
        // ATQB too short?
        if (Demod.len < 14)
        {
        // ATQB too short?
        if (Demod.len < 14)
        {
@@ -996,7 +996,7 @@ int iso14443b_select_card()
     attrib[7] = Demod.output[10] & 0x0F;
     ComputeCrc14443(CRC_14443_B, attrib, 9, attrib + 9, attrib + 10);
     CodeAndTransmit14443bAsReader(attrib, sizeof(attrib));
     attrib[7] = Demod.output[10] & 0x0F;
     ComputeCrc14443(CRC_14443_B, attrib, 9, attrib + 9, attrib + 10);
     CodeAndTransmit14443bAsReader(attrib, sizeof(attrib));
-    GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+    GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
     // Answer to ATTRIB too short?
     if(Demod.len < 3)
        {
     // Answer to ATTRIB too short?
     if(Demod.len < 3)
        {
@@ -1056,12 +1056,12 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
        SpinDelay(200);
 
        clear_trace();
        SpinDelay(200);
 
        clear_trace();
-       set_tracing(TRUE);
+       set_tracing(true);
 
        // First command: wake up the tag using the INITIATE command
        uint8_t cmd1[] = {0x06, 0x00, 0x97, 0x5b};
        CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
 
        // First command: wake up the tag using the INITIATE command
        uint8_t cmd1[] = {0x06, 0x00, 0x97, 0x5b};
        CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
-       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
 
        if (Demod.len == 0) {
                DbpString("No response from tag");
 
        if (Demod.len == 0) {
                DbpString("No response from tag");
@@ -1077,7 +1077,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
        cmd1[1] = Demod.output[0];
        ComputeCrc14443(CRC_14443_B, cmd1, 2, &cmd1[2], &cmd1[3]);
        CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
        cmd1[1] = Demod.output[0];
        ComputeCrc14443(CRC_14443_B, cmd1, 2, &cmd1[2], &cmd1[3]);
        CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
-       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
        if (Demod.len != 3) {
                Dbprintf("Expected 3 bytes from tag, got %d", Demod.len);
                return;
        if (Demod.len != 3) {
                Dbprintf("Expected 3 bytes from tag, got %d", Demod.len);
                return;
@@ -1099,7 +1099,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
        cmd1[0] = 0x0B;
        ComputeCrc14443(CRC_14443_B, cmd1, 1 , &cmd1[1], &cmd1[2]);
        CodeAndTransmit14443bAsReader(cmd1, 3); // Only first three bytes for this one
        cmd1[0] = 0x0B;
        ComputeCrc14443(CRC_14443_B, cmd1, 1 , &cmd1[1], &cmd1[2]);
        CodeAndTransmit14443bAsReader(cmd1, 3); // Only first three bytes for this one
-       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
        if (Demod.len != 10) {
                Dbprintf("Expected 10 bytes from tag, got %d", Demod.len);
                return;
        if (Demod.len != 10) {
                Dbprintf("Expected 10 bytes from tag, got %d", Demod.len);
                return;
@@ -1128,7 +1128,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
                cmd1[1] = i;
                ComputeCrc14443(CRC_14443_B, cmd1, 2, &cmd1[2], &cmd1[3]);
                CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
                cmd1[1] = i;
                ComputeCrc14443(CRC_14443_B, cmd1, 2, &cmd1[2], &cmd1[3]);
                CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1));
-               GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+               GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
                if (Demod.len != 6) { // Check if we got an answer from the tag
                        DbpString("Expected 6 bytes from tag, got less...");
                        return;
                if (Demod.len != 6) { // Check if we got an answer from the tag
                        DbpString("Expected 6 bytes from tag, got less...");
                        return;
@@ -1174,13 +1174,13 @@ void RAMFUNC SnoopIso14443b(void)
        // We won't start recording the frames that we acquire until we trigger;
        // a good trigger condition to get started is probably when we see a
        // response from the tag.
        // We won't start recording the frames that we acquire until we trigger;
        // a good trigger condition to get started is probably when we see a
        // response from the tag.
-       int triggered = TRUE;                   // TODO: set and evaluate trigger condition
+       int triggered = true;                   // TODO: set and evaluate trigger condition
 
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        BigBuf_free();
 
        clear_trace();
 
        FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
        BigBuf_free();
 
        clear_trace();
-       set_tracing(TRUE);
+       set_tracing(true);
 
        // The DMA buffer, used to stream samples from the FPGA
        int8_t *dmaBuf = (int8_t*) BigBuf_malloc(ISO14443B_DMA_BUFFER_SIZE);
 
        // The DMA buffer, used to stream samples from the FPGA
        int8_t *dmaBuf = (int8_t*) BigBuf_malloc(ISO14443B_DMA_BUFFER_SIZE);
@@ -1217,8 +1217,8 @@ void RAMFUNC SnoopIso14443b(void)
        FpgaSetupSscDma((uint8_t*) dmaBuf, ISO14443B_DMA_BUFFER_SIZE);
        uint8_t parity[MAX_PARITY_SIZE];
 
        FpgaSetupSscDma((uint8_t*) dmaBuf, ISO14443B_DMA_BUFFER_SIZE);
        uint8_t parity[MAX_PARITY_SIZE];
 
-       bool TagIsActive = FALSE;
-       bool ReaderIsActive = FALSE;
+       bool TagIsActive = false;
+       bool ReaderIsActive = false;
 
        // And now we loop, receiving samples.
        for(;;) {
 
        // And now we loop, receiving samples.
        for(;;) {
@@ -1259,7 +1259,7 @@ void RAMFUNC SnoopIso14443b(void)
                if (!TagIsActive) {                                                     // no need to try decoding reader data if the tag is sending
                        if(Handle14443bUartBit(ci & 0x01)) {
                                if(triggered && tracing) {
                if (!TagIsActive) {                                                     // no need to try decoding reader data if the tag is sending
                        if(Handle14443bUartBit(ci & 0x01)) {
                                if(triggered && tracing) {
-                                       LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE);
+                                       LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, true);
                                }
                                /* And ready to receive another command. */
                                UartReset();
                                }
                                /* And ready to receive another command. */
                                UartReset();
@@ -1269,7 +1269,7 @@ void RAMFUNC SnoopIso14443b(void)
                        }
                        if(Handle14443bUartBit(cq & 0x01)) {
                                if(triggered && tracing) {
                        }
                        if(Handle14443bUartBit(cq & 0x01)) {
                                if(triggered && tracing) {
-                                       LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE);
+                                       LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, true);
                                }
                                /* And ready to receive another command. */
                                UartReset();
                                }
                                /* And ready to receive another command. */
                                UartReset();
@@ -1287,9 +1287,9 @@ void RAMFUNC SnoopIso14443b(void)
                                if(tracing)
                                {
                                        uint8_t parity[MAX_PARITY_SIZE];
                                if(tracing)
                                {
                                        uint8_t parity[MAX_PARITY_SIZE];
-                                       LogTrace(Demod.output, Demod.len, samples, samples, parity, FALSE);
+                                       LogTrace(Demod.output, Demod.len, samples, samples, parity, false);
                                }
                                }
-                               triggered = TRUE;
+                               triggered = true;
 
                                // And ready to receive another response.
                                DemodReset();
 
                                // And ready to receive another response.
                                DemodReset();
@@ -1330,12 +1330,12 @@ void SendRawCommand14443B(uint32_t datalen, uint32_t recv, uint8_t powerfield, u
        FpgaSetupSsc();
 
        if (datalen){
        FpgaSetupSsc();
 
        if (datalen){
-               set_tracing(TRUE);
+               set_tracing(true);
                
                CodeAndTransmit14443bAsReader(data, datalen);
 
                if(recv) {
                
                CodeAndTransmit14443bAsReader(data, datalen);
 
                if(recv) {
-                       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
+                       GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, true);
                        uint16_t iLen = MIN(Demod.len, USB_CMD_DATA_SIZE);
                        cmd_send(CMD_ACK, iLen, 0, 0, Demod.output, iLen);
                }
                        uint16_t iLen = MIN(Demod.len, USB_CMD_DATA_SIZE);
                        cmd_send(CMD_ACK, iLen, 0, 0, Demod.output, iLen);
                }
index e11e5a9ccc6e232fa7374bf2c7f5fb1e2390ec66..1f0b8193c0cf96ab76b31941bcb99ed94194aae0 100644 (file)
@@ -305,7 +305,7 @@ static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
        //spindelay(60);        // greg - experiment to get rid of some of the 0 byte/failed reads
        c = 0;
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
        //spindelay(60);        // greg - experiment to get rid of some of the 0 byte/failed reads
        c = 0;
-       getNext = FALSE;
+       getNext = false;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
@@ -444,7 +444,7 @@ static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
        //spindelay(60);        // greg - experiment to get rid of some of the 0 byte/failed reads
        c = 0;
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
        //spindelay(60);        // greg - experiment to get rid of some of the 0 byte/failed reads
        c = 0;
-       getNext = FALSE;
+       getNext = false;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
@@ -612,7 +612,7 @@ void AcquireRawAdcSamplesIso15693(void)
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
 
        c = 0;
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
 
        c = 0;
-       getNext = FALSE;
+       getNext = false;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
@@ -666,7 +666,7 @@ void RecordRawAdcSamplesIso15693(void)
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
 
        c = 0;
        FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
 
        c = 0;
-       getNext = FALSE;
+       getNext = false;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
                        AT91C_BASE_SSC->SSC_THR = 0x43;
index f3bbbf84e19f6f2527ba787a497e70437fda213e..911ba8da1c62e81d8fc7973928e931bf87cede3e 100644 (file)
@@ -568,7 +568,7 @@ static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt)
        uint8_t wavesPerClock = clock/fc;
        uint8_t mod = clock % fc;    //modifier
        uint8_t modAdj = fc/mod;     //how often to apply modifier
        uint8_t wavesPerClock = clock/fc;
        uint8_t mod = clock % fc;    //modifier
        uint8_t modAdj = fc/mod;     //how often to apply modifier
-       bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk=TRUE;
+       bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk=true;
        // loop through clock - step field clock
        for (uint8_t idx=0; idx < wavesPerClock; idx++){
                // put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave)
        // loop through clock - step field clock
        for (uint8_t idx=0; idx < wavesPerClock; idx++){
                // put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave)
@@ -820,9 +820,9 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
 
        for (i=0; i<size; i++){
                if (BitStream[i] == curPhase){
 
        for (i=0; i<size; i++){
                if (BitStream[i] == curPhase){
-                       pskSimBit(carrier, &n, clk, &curPhase, FALSE);
+                       pskSimBit(carrier, &n, clk, &curPhase, false);
                } else {
                } else {
-                       pskSimBit(carrier, &n, clk, &curPhase, TRUE);
+                       pskSimBit(carrier, &n, clk, &curPhase, true);
                }
        }
        Dbprintf("Simulating with Carrier: %d, clk: %d, invert: %d, n: %d",carrier, clk, invert, n);
                }
        }
        Dbprintf("Simulating with Carrier: %d, clk: %d, invert: %d, n: %d",carrier, clk, invert, n);
index 3854b5899611e1f573352467dfeac34c6e278cd1..ca513cec953c897b00833595ce07781a402085e0 100644 (file)
@@ -1149,7 +1149,7 @@ static bool isBlockTrailer(int blockN) {
        if (blockN >= 128 && blockN <= 256) {\r
                return ((blockN & 0x0F) == 0x0F);\r
        }\r
        if (blockN >= 128 && blockN <= 256) {\r
                return ((blockN & 0x0F) == 0x0F);\r
        }\r
-       return FALSE;\r
+       return false;\r
 }\r
 \r
 void MifareCWipe(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){\r
 }\r
 \r
 void MifareCWipe(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){\r
index f20f2557868b007ac42d2553af605721a42b0456..5391e5f9af1c35f0bc2e8b44d600955610fa52c0 100644 (file)
@@ -35,7 +35,7 @@ bool MfSniffInit(void){
        sniffSAK = 0;
        sniffUIDType = SNF_UID_4;
 
        sniffSAK = 0;
        sniffUIDType = SNF_UID_4;
 
-       return FALSE;
+       return false;
 }
 
 bool MfSniffEnd(void){
 }
 
 bool MfSniffEnd(void){
@@ -43,7 +43,7 @@ bool MfSniffEnd(void){
        cmd_send(CMD_ACK,0,0,0,0,0);
        LED_B_OFF();
 
        cmd_send(CMD_ACK,0,0,0,0,0);
        LED_B_OFF();
 
-       return FALSE;
+       return false;
 }
 
 bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
 }
 
 bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
@@ -112,7 +112,7 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
                        sniffBuf[11] = sniffSAK;
                        sniffBuf[12] = 0xFF;
                        sniffBuf[13] = 0xFF;
                        sniffBuf[11] = sniffSAK;
                        sniffBuf[12] = 0xFF;
                        sniffBuf[13] = 0xFF;
-                       LogTrace(sniffBuf, 14, 0, 0, NULL, TRUE);
+                       LogTrace(sniffBuf, 14, 0, 0, NULL, true);
                        sniffState = SNF_CARD_CMD;
                }       // intentionally no break;
                case SNF_CARD_CMD:{     
                        sniffState = SNF_CARD_CMD;
                }       // intentionally no break;
                case SNF_CARD_CMD:{     
@@ -127,14 +127,14 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
        }
 
 
        }
 
 
-       return FALSE;
+       return false;
 }
 
 bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) {
        if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) {
                return intMfSniffSend();
        }
 }
 
 bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) {
        if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) {
                return intMfSniffSend();
        }
-       return FALSE;
+       return false;
 }
 
 // internal sending function. not a RAMFUNC.
 }
 
 // internal sending function. not a RAMFUNC.
@@ -162,5 +162,5 @@ bool intMfSniffSend() {
 
        clear_trace();
        
 
        clear_trace();
        
-       return TRUE;
+       return true;
 }
 }
index 94ed809d2a5aaf8f6a8e7e311c1cf8a6cc00f91e..79c123dff624e6c030df9307b16b72d38e7631f6 100644 (file)
@@ -175,6 +175,7 @@ reswitch:   switch (ch = (u_char)*fmt++) {
                                padc = '0';
                                goto reswitch;
                        }
                                padc = '0';
                                goto reswitch;
                        }
+                       // intentionally fall through to next case
                case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
                                for (n = 0;; ++fmt) {
                case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
                                for (n = 0;; ++fmt) {
index 17c3120987e7667a52c21c21194596664f40be18..93906a7d472bbf114f92a19e5b5bf962fe4323a4 100644 (file)
@@ -361,7 +361,7 @@ int CmdHFList(const char *Cmd)
        char param2 = '\0';
        char param3 = '\0';
        char type[40] = {0};
        char param2 = '\0';
        char param3 = '\0';
        char type[40] = {0};
-       char filename[FILE_PATH_SIZE];
+       char filename[FILE_PATH_SIZE] = {0};
        uint8_t protocol = 0;
        
        // parse command line
        uint8_t protocol = 0;
        
        // parse command line
index 859dec2f6bfd6447a279c7600784db9251cc504b..03ab0b5a69f8b3e83e725af73b99ed3b464f84fa 100644 (file)
@@ -486,12 +486,12 @@ int CmdHF14AInfo(const char *Cmd)
 
        
        // try to see if card responses to "chinese magic backdoor" commands.
 
        
        // try to see if card responses to "chinese magic backdoor" commands.
-       mfCIdentify();
+       (void)mfCIdentify();
        
        if (isMifareClassic) {          
                switch(DetectClassicPrng()) {
                case 0:
        
        if (isMifareClassic) {          
                switch(DetectClassicPrng()) {
                case 0:
-                       PrintAndLog("Prng detection: HARDEND (hardnested)");            
+                       PrintAndLog("Prng detection: HARDENED (hardnested)");           
                        break;
                case 1:
                        PrintAndLog("Prng detection: WEAK");
                        break;
                case 1:
                        PrintAndLog("Prng detection: WEAK");
@@ -1032,12 +1032,9 @@ static command_t CommandTable[] =
 };
 
 int CmdHF14A(const char *Cmd) {
 };
 
 int CmdHF14A(const char *Cmd) {
-       // flush
-       WaitForResponseTimeout(CMD_ACK,NULL,100);
-
-       // parse
-  CmdsParse(CommandTable, Cmd);
-  return 0;
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);
+       CmdsParse(CommandTable, Cmd);
+       return 0;
 }
 
 int CmdHelp(const char *Cmd)
 }
 
 int CmdHelp(const char *Cmd)
index ac1f4268eb7f057b36d8a3a6a7ea7952a2b9c6e5..76664bf59616468ba55c832dae8da24e6ba5e2e6 100644 (file)
@@ -202,10 +202,7 @@ int CmdHelp(const char *Cmd)
 
 int CmdHFEPA(const char *Cmd)
 {
 
 int CmdHFEPA(const char *Cmd)
 {
-       // flush
-       WaitForResponseTimeout(CMD_ACK,NULL,100);
-
-       // parse
-  CmdsParse(CommandTable, Cmd);
-  return 0;
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);
+       CmdsParse(CommandTable, Cmd);
+       return 0;
 }
 }
index c87aa23779724bbf4206afb231dc50f304558497..5538b6fb8a50ff71b2b9d2127cf72824c33ceaca 100644 (file)
@@ -559,8 +559,10 @@ bool NestedCheckKey(uint64_t key, TAuthData *ad, uint8_t *cmd, uint8_t cmdsize,
        uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ad->ar_enc;
        uint32_t at1 = crypto1_word(pcs, 0, 0) ^ ad->at_enc;
 
        uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ad->ar_enc;
        uint32_t at1 = crypto1_word(pcs, 0, 0) ^ ad->at_enc;
 
-       if (!(ar == ar1 && at == at1 && NTParityChk(ad, nt1)))
+       if (!(ar == ar1 && at == at1 && NTParityChk(ad, nt1))) {
+               crypto1_destroy(pcs);
                return false;
                return false;
+       }
 
        memcpy(buf, cmd, cmdsize);
        mf_crypto1_decrypt(pcs, buf, cmdsize, 0);
 
        memcpy(buf, cmd, cmdsize);
        mf_crypto1_decrypt(pcs, buf, cmdsize, 0);
index b50d6013dec48a6a68142ec5b2bd36ae827c7898..e2a4ba1e2f09da71decceb0f82ad37f8857655a4 100644 (file)
@@ -726,7 +726,6 @@ int CmdHF14AMfNested(const char *Cmd)
                                                blockNo = i * 4;\r
                                                keyType = j;\r
                                                num_to_bytes(e_sector[i].Key[j], 6, key);\r
                                                blockNo = i * 4;\r
                                                keyType = j;\r
                                                num_to_bytes(e_sector[i].Key[j], 6, key);\r
-                                               \r
                                                keyFound = true;\r
                                                break;\r
                                        }\r
                                                keyFound = true;\r
                                                break;\r
                                        }\r
@@ -737,6 +736,7 @@ int CmdHF14AMfNested(const char *Cmd)
                        // Can't found a key....\r
                        if (!keyFound) {\r
                                PrintAndLog("Can't found any of the known keys.");\r
                        // Can't found a key....\r
                        if (!keyFound) {\r
                                PrintAndLog("Can't found any of the known keys.");\r
+                               free(e_sector);\r
                                return 4;\r
                        }\r
                        PrintAndLog("--auto key. block no:%3d, key type:%c key:%s", blockNo, keyType?'B':'A', sprint_hex(key, 6));\r
                                return 4;\r
                        }\r
                        PrintAndLog("--auto key. block no:%3d, key type:%c key:%s", blockNo, keyType?'B':'A', sprint_hex(key, 6));\r
@@ -1187,7 +1187,10 @@ int CmdHF14AMfChk(const char *Cmd)
 \r
        // initialize storage for found keys\r
        e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
 \r
        // initialize storage for found keys\r
        e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
-       if (e_sector == NULL) return 1;\r
+       if (e_sector == NULL) {\r
+               free(keyBlock);\r
+               return 1;\r
+       }\r
        for (uint8_t keyAB = 0; keyAB < 2; keyAB++) {\r
                for (uint16_t sectorNo = 0; sectorNo < SectorsCnt; sectorNo++) {\r
                        e_sector[sectorNo].Key[keyAB] = 0xffffffffffff;\r
        for (uint8_t keyAB = 0; keyAB < 2; keyAB++) {\r
                for (uint16_t sectorNo = 0; sectorNo < SectorsCnt; sectorNo++) {\r
                        e_sector[sectorNo].Key[keyAB] = 0xffffffffffff;\r
@@ -2666,11 +2669,9 @@ static command_t CommandTable[] =
 \r
 int CmdHFMF(const char *Cmd)\r
 {\r
 \r
 int CmdHFMF(const char *Cmd)\r
 {\r
-       // flush\r
-       WaitForResponseTimeout(CMD_ACK,NULL,100);\r
-\r
-  CmdsParse(CommandTable, Cmd);\r
-  return 0;\r
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);\r
+       CmdsParse(CommandTable, Cmd);\r
+       return 0;\r
 }\r
 \r
 int CmdHelp(const char *Cmd)\r
 }\r
 \r
 int CmdHelp(const char *Cmd)\r
index be618d6e7286d9583d13d6dd6f2476eb95fef98e..4a379c7129e14a4c948cf2d7a0ef2f3b898d9b6c 100644 (file)
@@ -276,7 +276,6 @@ static void init_bitflip_bitarrays(void)
                                if (bytesread != filesize) {
                                        printf("File read error with %s. Aborting...\n", state_file_name);
                                        fclose(statesfile);
                                if (bytesread != filesize) {
                                        printf("File read error with %s. Aborting...\n", state_file_name);
                                        fclose(statesfile);
-                                       inflateEnd(&compressed_stream);
                                        exit(5);
                                }
                                fclose(statesfile);
                                        exit(5);
                                }
                                fclose(statesfile);
index e4115d71606db2079862040aca3d8c04f8f67f53..1077ec992fe9826e650ff4557fde8362c208f118 100644 (file)
@@ -1834,7 +1834,7 @@ static command_t CommandTable[] =
 };
 
 int CmdHFMFUltra(const char *Cmd){
 };
 
 int CmdHFMFUltra(const char *Cmd){
-       WaitForResponseTimeout(CMD_ACK,NULL,100);
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);
        CmdsParse(CommandTable, Cmd);
        return 0;
 }
        CmdsParse(CommandTable, Cmd);
        return 0;
 }
index b0b8a3d2c642f0edaa3fecb623cb24f766a0847b..6058cabe2ab8b8b18d671a00ba5427e6cb38f228 100644 (file)
@@ -455,7 +455,7 @@ int CmdHFTopazReader(const char *Cmd)
        PrintAndLog("HR0  : %02x (%sa Topaz tag (%scapable of carrying a NDEF message), %s memory map)", rid_response[0], 
                                                (rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
                                                (rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
        PrintAndLog("HR0  : %02x (%sa Topaz tag (%scapable of carrying a NDEF message), %s memory map)", rid_response[0], 
                                                (rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
                                                (rid_response[0] & 0xF0) == 0x10 ? "" : "not ",
-                                               (rid_response[0] & 0x0F) == 0x10 ? "static" : "dynamic");
+                                               (rid_response[0] & 0x0F) == 0x01 ? "static" : "dynamic");
        PrintAndLog("HR1  : %02x", rid_response[1]);
        
        status = topaz_rall(uid_echo, rall_response);
        PrintAndLog("HR1  : %02x", rid_response[1]);
        
        status = topaz_rall(uid_echo, rall_response);
@@ -554,10 +554,7 @@ static command_t CommandTable[] =
 
 
 int CmdHFTopaz(const char *Cmd) {
 
 
 int CmdHFTopaz(const char *Cmd) {
-       // flush
-       WaitForResponseTimeout(CMD_ACK,NULL,100);
-
-       // parse
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);
        CmdsParse(CommandTable, Cmd);
        return 0;
 }
        CmdsParse(CommandTable, Cmd);
        return 0;
 }
index 0fd8801b8e83010068e818e096361dafcdb4f58d..8eef23595bd383159291a4a76d32b12b77f98939 100644 (file)
@@ -66,6 +66,7 @@ int CmdLFHitagList(const char *Cmd)
        if (strlen(filename) > 0) {
                if ((pf = fopen(filename,"wb")) == NULL) {
                        PrintAndLog("Error: Could not open file [%s]",filename);
        if (strlen(filename) > 0) {
                if ((pf = fopen(filename,"wb")) == NULL) {
                        PrintAndLog("Error: Could not open file [%s]",filename);
+                       free(got);
                        return 1;
                }
        }
                        return 1;
                }
        }
@@ -166,11 +167,11 @@ int CmdLFHitagSim(const char *Cmd) {
                        return 1;
                }
                tag_mem_supplied = true;
                        return 1;
                }
                tag_mem_supplied = true;
-               if (fread(c.d.asBytes,48,1,pf) == 0) {
-      PrintAndLog("Error: File reading error");
-      fclose(pf);
+               if (fread(c.d.asBytes,1,48,pf) != 48) {
+                       PrintAndLog("Error: File reading error");
+                       fclose(pf);
                        return 1;
                        return 1;
-    }
+               }
                fclose(pf);
        } else {
                tag_mem_supplied = false;
                fclose(pf);
        } else {
                tag_mem_supplied = false;
@@ -289,7 +290,7 @@ int CmdLFHitagSimS(const char *Cmd) {
                        return 1;
                }
                tag_mem_supplied = true;
                        return 1;
                }
                tag_mem_supplied = true;
-               if (fread(c.d.asBytes, 4*64, 1, pf) == 0) {
+               if (fread(c.d.asBytes, 1, 4*64, pf) != 4*64) {
                        PrintAndLog("Error: File reading error");
                        fclose(pf);
                        return 1;
                        PrintAndLog("Error: File reading error");
                        fclose(pf);
                        return 1;
@@ -321,9 +322,9 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
                        return 1;
                }
                file_given = true;
                        return 1;
                }
                file_given = true;
-               if (fread(c.d.asBytes,8*60,1,pf) == 0) {
-      PrintAndLog("Error: File reading error");
-      fclose(pf);
+               if (fread(c.d.asBytes,1,8*60,pf) != 8*60) {
+                       PrintAndLog("Error: File reading error");
+                       fclose(pf);
                        return 1;
         }
                fclose(pf);
                        return 1;
         }
                fclose(pf);
index b30231c57a7a673c9c3681ef3d704f1b9f81d6f8..02c906d0f80fb5c07f7511d3265e9e3cbee064c2 100644 (file)
@@ -287,7 +287,7 @@ int CmdIndalaDemod(const char *Cmd) {
 }
 
 int CmdIndalaClone(const char *Cmd) {
 }
 
 int CmdIndalaClone(const char *Cmd) {
-       UsbCommand c;
+       UsbCommand c = {0};
        unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
 
        uid1 =  uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
        unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
 
        uid1 =  uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
index 3d11afe5e2b73c7fea79ff1fba6990e7dfbf5b5f..5a3db8eae4803f3e7f44dcb5620c110886e22132 100644 (file)
@@ -105,7 +105,7 @@ static struct crypto_pk *crypto_pk_polarssl_open_rsa(va_list vl)
        int res = rsa_check_pubkey(&cp->ctx);
        if(res != 0) {
                fprintf(stderr, "PolarSSL public key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
        int res = rsa_check_pubkey(&cp->ctx);
        if(res != 0) {
                fprintf(stderr, "PolarSSL public key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
-
+               free(cp);
                return NULL;
        }
 
                return NULL;
        }
 
@@ -150,6 +150,7 @@ static struct crypto_pk *crypto_pk_polarssl_open_priv_rsa(va_list vl)
        int res = rsa_check_privkey(&cp->ctx);
        if(res != 0) {
                fprintf(stderr, "PolarSSL private key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
        int res = rsa_check_privkey(&cp->ctx);
        if(res != 0) {
                fprintf(stderr, "PolarSSL private key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);
+               free(cp);
                return NULL;
        }
 
                return NULL;
        }
 
@@ -184,6 +185,7 @@ static struct crypto_pk *crypto_pk_polarssl_genkey_rsa(va_list vl)
        int res = rsa_gen_key(&cp->ctx, &myrand, NULL, nbits, exp);
        if (res) {
                fprintf(stderr, "PolarSSL private key generation error res=%x exp=%d nbits=%d.\n", res * -1, exp, nbits);
        int res = rsa_gen_key(&cp->ctx, &myrand, NULL, nbits, exp);
        if (res) {
                fprintf(stderr, "PolarSSL private key generation error res=%x exp=%d nbits=%d.\n", res * -1, exp, nbits);
+               free(cp);
                return NULL;
        }
        
                return NULL;
        }
        
@@ -216,6 +218,7 @@ static unsigned char *crypto_pk_polarssl_encrypt(const struct crypto_pk *_cp, co
        res = rsa_public(&cp->ctx, buf, result);
        if(res) {
                printf("RSA encrypt failed. Error: %x data len: %zd key len: %zd\n", res * -1, len, keylen);
        res = rsa_public(&cp->ctx, buf, result);
        if(res) {
                printf("RSA encrypt failed. Error: %x data len: %zd key len: %zd\n", res * -1, len, keylen);
+               free(result);
                return NULL;
        }
        
                return NULL;
        }
        
@@ -242,6 +245,7 @@ static unsigned char *crypto_pk_polarssl_decrypt(const struct crypto_pk *_cp, co
        res = rsa_private(&cp->ctx, buf, result); // CHECK???
        if(res) {
                printf("RSA decrypt failed. Error: %x data len: %zd key len: %zd\n", res * -1, len, keylen);
        res = rsa_private(&cp->ctx, buf, result); // CHECK???
        if(res) {
                printf("RSA decrypt failed. Error: %x data len: %zd key len: %zd\n", res * -1, len, keylen);
+               free(result);
                return NULL;
        }
        
                return NULL;
        }
        
index e43ebd1b6932e07ecf5dcb29fa821c066d92f77d..9a443cb84fce8df45ee0ec70ca3d6e9b26753b36 100644 (file)
@@ -40,7 +40,7 @@ static const uint8_t elf_ident[] = {
 
 // Turn PHDRs into flasher segments, checking for PHDR sanity and merging adjacent
 // unaligned segments if needed
 
 // Turn PHDRs into flasher segments, checking for PHDR sanity and merging adjacent
 // unaligned segments if needed
-static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, int num_phdrs)
+static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, uint16_t num_phdrs)
 {
        Elf32_Phdr *phdr = phdrs;
        flash_seg_t *seg;
 {
        Elf32_Phdr *phdr = phdrs;
        flash_seg_t *seg;
@@ -191,7 +191,7 @@ int flash_load(flash_file_t *ctx, const char *name, bool can_write_bl)
        FILE *fd = NULL;
        Elf32_Ehdr ehdr;
        Elf32_Phdr *phdrs = NULL;
        FILE *fd = NULL;
        Elf32_Ehdr ehdr;
        Elf32_Phdr *phdrs = NULL;
-       int num_phdrs;
+       uint16_t num_phdrs;
        int res;
 
        fd = fopen(name, "rb");
        int res;
 
        fd = fopen(name, "rb");
@@ -270,7 +270,7 @@ fail:
 // Get the state of the proxmark, backwards compatible
 static int get_proxmark_state(uint32_t *state)
 {
 // Get the state of the proxmark, backwards compatible
 static int get_proxmark_state(uint32_t *state)
 {
-       UsbCommand c;
+       UsbCommand c = {0};
        c.cmd = CMD_DEVICE_INFO;
        SendCommand(&c);
        UsbCommand resp;
        c.cmd = CMD_DEVICE_INFO;
        SendCommand(&c);
        UsbCommand resp;
index fc298a8b87b6bb948be72a69d4c731d559e1ede6..bd1e8be2d374ce1912ea14dde76ea87ef51e5de0 100644 (file)
@@ -108,7 +108,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
 
                for(uint16_t j = 0; j < num_infiles; j++) {
                        for(uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) {
 
                for(uint16_t j = 0; j < num_infiles; j++) {
                        for(uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) {
-                               c = fgetc(infile[j]);
+                               c = (uint8_t)fgetc(infile[j]);
                                if (!feof(infile[j])) {
                                        fpga_config[i++] = c;
                                } else if (num_infiles > 1) {
                                if (!feof(infile[j])) {
                                        fpga_config[i++] = c;
                                } else if (num_infiles > 1) {
index 2d69cfae14208f56f89a8dc03bcec1986272cd8d..9be04b4d6f0d7611520e05e58a73be800d393fdc 100644 (file)
@@ -328,7 +328,7 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
        struct Crypto1State *p1, *p2, *p3, *p4;\r
 \r
        // flush queue\r
        struct Crypto1State *p1, *p2, *p3, *p4;\r
 \r
        // flush queue\r
-       WaitForResponseTimeout(CMD_ACK, NULL, 100);\r
+       (void)WaitForResponseTimeout(CMD_ACK,NULL,100);\r
 \r
        UsbCommand c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}};\r
        memcpy(c.d.asBytes, key, 6);\r
 \r
        UsbCommand c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}};\r
        memcpy(c.d.asBytes, key, 6);\r
@@ -910,6 +910,7 @@ int mfTraceDecode(uint8_t *data_src, int len, uint8_t parity, bool wantSaveToEml
                                        uint32_t nr1 = crypto1_word(pcs, nr_enc, 1) ^ nr_enc;\r
                                        uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ar_enc;\r
                                        uint32_t at1 = crypto1_word(pcs, 0, 0) ^ at_enc;\r
                                        uint32_t nr1 = crypto1_word(pcs, nr_enc, 1) ^ nr_enc;\r
                                        uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ar_enc;\r
                                        uint32_t at1 = crypto1_word(pcs, 0, 0) ^ at_enc;\r
+                                       crypto1_destroy(pcs);\r
                                        printf("key> the same key test. nr1: %08x ar1: %08x at1: %08x \n", nr1, ar1, at1);\r
 \r
                                        if (NTParityCheck(nt1))\r
                                        printf("key> the same key test. nr1: %08x ar1: %08x at1: %08x \n", nr1, ar1, at1);\r
 \r
                                        if (NTParityCheck(nt1))\r
index e899174c419870e2e78014e609f0f3faa2f38f04..18749158c1110f7e0bc6031f558b6d5baff6f61f 100644 (file)
@@ -62,12 +62,9 @@ extern "C" void MainGraphics(void)
 extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present)
 {
 #ifdef Q_WS_X11
 extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present)
 {
 #ifdef Q_WS_X11
-       bool useGUI = getenv("DISPLAY") != 0;
-#else
-       bool useGUI = true;
-#endif
-       if (!useGUI)
+       if (getenv("DISPLAY") == NULL)
                return;
                return;
+#endif
 
        main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present);
        gui = new ProxGuiQT(argc, argv, main_loop_thread);
 
        main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present);
        gui = new ProxGuiQT(argc, argv, main_loop_thread);
index e43311ee2ff1af0ed65387079d7d53c50e181953..5f7199fc09202ea2660c55fb7043c027a7b197bf 100644 (file)
@@ -110,7 +110,6 @@ class ProxGuiQT : public QObject
                ProxWidget *plotwidget;
                int argc;
                char **argv;
                ProxWidget *plotwidget;
                int argc;
                char **argv;
-               void (*main_func)(void);
                WorkerThread *proxmarkThread;
        
        public:
                WorkerThread *proxmarkThread;
        
        public:
index e73c7138930e4734977f81c5ba3dd086b3e2e04c..232da889703618914bd8e4ec73fcacb0332d559a 100644 (file)
@@ -221,7 +221,7 @@ static int l_iso14443b_crc(lua_State *L)
        unsigned char buf[USB_CMD_DATA_SIZE];
        size_t len = 0;
        const char *data = luaL_checklstring(L, 1, &len);
        unsigned char buf[USB_CMD_DATA_SIZE];
        size_t len = 0;
        const char *data = luaL_checklstring(L, 1, &len);
-       if (USB_CMD_DATA_SIZE < len)
+       if (len > USB_CMD_DATA_SIZE-2)
                len =  USB_CMD_DATA_SIZE-2;
 
        for (int i = 0; i < len; i += 2) {
                len =  USB_CMD_DATA_SIZE-2;
 
        for (int i = 0; i < len; i += 2) {
index 32158adab3403fa394f1406d40961692ad19425d..435e41f39cebdb8b5eea32ac81b16a6358113254 100644 (file)
@@ -117,7 +117,7 @@ uint64_t msclock() {
        #include <sys/timeb.h>
        struct _timeb t;
        _ftime(&t);
        #include <sys/timeb.h>
        struct _timeb t;
        _ftime(&t);
-       return 1000 * t.time + t.millitm;
+       return 1000 * (uint64_t)t.time + t.millitm;
 
 // NORMAL CODE (use _ftime_s)
        //struct _timeb t;
 
 // NORMAL CODE (use _ftime_s)
        //struct _timeb t;
index 4a59636e7f6cc156e438a332208116ccd3eb9439..6fb6624fa1cbe5b36b3dcd3fc0a3358b3ecba57d 100644 (file)
@@ -61,9 +61,6 @@
 #define SPI_FPGA_MODE  0
 #define SPI_LCD_MODE   1
 
 #define SPI_FPGA_MODE  0
 #define SPI_LCD_MODE   1
 
-#define TRUE 1
-#define FALSE 0
-
 //#define PACKED __attribute__((__packed__))
 
 #define LED_A_ON()             HIGH(GPIO_LED_A)
 //#define PACKED __attribute__((__packed__))
 
 #define LED_A_ON()             HIGH(GPIO_LED_A)
index a5665ab2e398042bccba48b753b42e8862cb95fd..d84305d0da486ea0427749411fa8856c4ebf7552 100755 (executable)
@@ -10,7 +10,7 @@
 // 32 bit recover key from 2 nonces
 int main (int argc, char *argv[]) {
 
 // 32 bit recover key from 2 nonces
 int main (int argc, char *argv[]) {
 
-  nonces_t data;
+  nonces_t data = {0};
   uint32_t ks2;     // keystream used to encrypt reader response
   uint64_t key;     // recovered key
 
   uint32_t ks2;     // keystream used to encrypt reader response
   uint64_t key;     // recovered key
 
Impressum, Datenschutz