mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Coverity-fixes in armsrc
This commit is contained in:
parent
97d582a692
commit
2ed270a854
6 changed files with 104 additions and 91 deletions
|
@ -419,7 +419,7 @@ int EPA_Setup()
|
||||||
// return code
|
// return code
|
||||||
int return_code = 0;
|
int return_code = 0;
|
||||||
// card UID
|
// card UID
|
||||||
uint8_t uid[8];
|
uint8_t uid[10];
|
||||||
// card select information
|
// card select information
|
||||||
iso14a_card_select_t card_select_info;
|
iso14a_card_select_t card_select_info;
|
||||||
// power up the field
|
// power up the field
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
||||||
case RHT2F_PASSWORD: {
|
case RHT2F_PASSWORD: {
|
||||||
Dbprintf("List identifier in password mode");
|
Dbprintf("List identifier in password mode");
|
||||||
memcpy(password,htd->pwd.password,4);
|
memcpy(password,htd->pwd.password,4);
|
||||||
blocknr = 0;
|
blocknr = 0;
|
||||||
bQuitTraceFull = false;
|
bQuitTraceFull = false;
|
||||||
bQuiet = false;
|
bQuiet = false;
|
||||||
bPwd = false;
|
bPwd = false;
|
||||||
|
@ -1158,7 +1158,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
||||||
|
|
||||||
case RHT2F_CRYPTO: {
|
case RHT2F_CRYPTO: {
|
||||||
DbpString("Authenticating using key:");
|
DbpString("Authenticating using key:");
|
||||||
memcpy(key,htd->crypto.key,6);
|
memcpy(key,htd->crypto.key,4);
|
||||||
Dbhexdump(6,key,false);
|
Dbhexdump(6,key,false);
|
||||||
blocknr = 0;
|
blocknr = 0;
|
||||||
bQuiet = false;
|
bQuiet = false;
|
||||||
|
|
|
@ -1295,20 +1295,23 @@ static void TransmitIClassCommand(const uint8_t *cmd, int len, int *samples, int
|
||||||
FpgaSetupSsc();
|
FpgaSetupSsc();
|
||||||
|
|
||||||
if (wait)
|
if (wait)
|
||||||
if(*wait < 10)
|
{
|
||||||
*wait = 10;
|
if(*wait < 10) *wait = 10;
|
||||||
|
|
||||||
|
for(c = 0; c < *wait;) {
|
||||||
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
|
AT91C_BASE_SSC->SSC_THR = 0x00; // For exact timing!
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
|
volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
(void)r;
|
||||||
|
}
|
||||||
|
WDT_HIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for(c = 0; c < *wait;) {
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
|
||||||
AT91C_BASE_SSC->SSC_THR = 0x00; // For exact timing!
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
|
||||||
volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
|
|
||||||
(void)r;
|
|
||||||
}
|
|
||||||
WDT_HIT();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t sendbyte;
|
uint8_t sendbyte;
|
||||||
bool firstpart = TRUE;
|
bool firstpart = TRUE;
|
||||||
|
|
|
@ -1726,7 +1726,13 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||||
if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
|
if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
|
||||||
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
|
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
|
||||||
// http://www.nxp.com/documents/application_note/AN10927.pdf
|
// 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;
|
uid_resp_len = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1936,7 +1942,8 @@ void ReaderMifare(bool first_try)
|
||||||
uint8_t uid[10];
|
uint8_t uid[10];
|
||||||
uint32_t cuid;
|
uint32_t cuid;
|
||||||
|
|
||||||
uint32_t nt, previous_nt;
|
uint32_t nt =0 ;
|
||||||
|
uint32_t previous_nt = 0;
|
||||||
static uint32_t nt_attacked = 0;
|
static uint32_t nt_attacked = 0;
|
||||||
byte_t par_list[8] = {0,0,0,0,0,0,0,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};
|
byte_t ks_list[8] = {0,0,0,0,0,0,0,0};
|
||||||
|
|
147
armsrc/lfops.c
147
armsrc/lfops.c
|
@ -1456,78 +1456,81 @@ int DemodPCF7931(uint8_t **outBlocks) {
|
||||||
|
|
||||||
for (bitidx = 0; i < GraphTraceLen; i++)
|
for (bitidx = 0; i < GraphTraceLen; i++)
|
||||||
{
|
{
|
||||||
if ( (GraphBuffer[i-1] > GraphBuffer[i] && dir == 1 && GraphBuffer[i] > lmax) || (GraphBuffer[i-1] < GraphBuffer[i] && dir == 0 && GraphBuffer[i] < lmin))
|
if ( (GraphBuffer[i-1] > GraphBuffer[i] && dir == 1 && GraphBuffer[i] > lmax) || (GraphBuffer[i-1] < GraphBuffer[i] && dir == 0 && GraphBuffer[i] < lmin))
|
||||||
{
|
{
|
||||||
lc = i - lastval;
|
lc = i - lastval;
|
||||||
lastval = i;
|
lastval = i;
|
||||||
|
|
||||||
// Switch depending on lc length:
|
// Switch depending on lc length:
|
||||||
// Tolerance is 1/8 of clock rate (arbitrary)
|
// Tolerance is 1/8 of clock rate (arbitrary)
|
||||||
if (abs(lc-clock/4) < tolerance) {
|
if (abs(lc-clock/4) < tolerance) {
|
||||||
// 16T0
|
// 16T0
|
||||||
if((i - pmc) == lc) { /* 16T0 was previous one */
|
if((i - pmc) == lc) { /* 16T0 was previous one */
|
||||||
/* It's a PMC ! */
|
/* It's a PMC ! */
|
||||||
i += (128+127+16+32+33+16)-1;
|
i += (128+127+16+32+33+16)-1;
|
||||||
lastval = i;
|
lastval = i;
|
||||||
pmc = 0;
|
pmc = 0;
|
||||||
block_done = 1;
|
block_done = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pmc = i;
|
pmc = i;
|
||||||
}
|
}
|
||||||
} else if (abs(lc-clock/2) < tolerance) {
|
} else if (abs(lc-clock/2) < tolerance) {
|
||||||
// 32TO
|
// 32TO
|
||||||
if((i - pmc) == lc) { /* 16T0 was previous one */
|
if((i - pmc) == lc) { /* 16T0 was previous one */
|
||||||
/* It's a PMC ! */
|
/* It's a PMC ! */
|
||||||
i += (128+127+16+32+33)-1;
|
i += (128+127+16+32+33)-1;
|
||||||
lastval = i;
|
lastval = i;
|
||||||
pmc = 0;
|
pmc = 0;
|
||||||
block_done = 1;
|
block_done = 1;
|
||||||
}
|
}
|
||||||
else if(half_switch == 1) {
|
else if(half_switch == 1) {
|
||||||
BitStream[bitidx++] = 0;
|
BitStream[bitidx++] = 0;
|
||||||
half_switch = 0;
|
half_switch = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
half_switch++;
|
half_switch++;
|
||||||
} else if (abs(lc-clock) < tolerance) {
|
} else if (abs(lc-clock) < tolerance) {
|
||||||
// 64TO
|
// 64TO
|
||||||
BitStream[bitidx++] = 1;
|
BitStream[bitidx++] = 1;
|
||||||
} else {
|
} else {
|
||||||
// Error
|
// Error
|
||||||
warnings++;
|
warnings++;
|
||||||
if (warnings > 10)
|
if (warnings > 10)
|
||||||
{
|
{
|
||||||
Dbprintf("Error: too many detection errors, aborting.");
|
Dbprintf("Error: too many detection errors, aborting.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block_done == 1) {
|
if(block_done == 1) {
|
||||||
if(bitidx == 128) {
|
if(bitidx == 128) {
|
||||||
for(j=0; j<16; j++) {
|
for(j=0; j<16; j++) {
|
||||||
Blocks[num_blocks][j] = 128*BitStream[j*8+7]+
|
Blocks[num_blocks][j] = 128*BitStream[j*8+7]+
|
||||||
64*BitStream[j*8+6]+
|
64*BitStream[j*8+6]+
|
||||||
32*BitStream[j*8+5]+
|
32*BitStream[j*8+5]+
|
||||||
16*BitStream[j*8+4]+
|
16*BitStream[j*8+4]+
|
||||||
8*BitStream[j*8+3]+
|
8*BitStream[j*8+3]+
|
||||||
4*BitStream[j*8+2]+
|
4*BitStream[j*8+2]+
|
||||||
2*BitStream[j*8+1]+
|
2*BitStream[j*8+1]+
|
||||||
BitStream[j*8];
|
BitStream[j*8];
|
||||||
}
|
}
|
||||||
num_blocks++;
|
num_blocks++;
|
||||||
}
|
}
|
||||||
bitidx = 0;
|
bitidx = 0;
|
||||||
block_done = 0;
|
block_done = 0;
|
||||||
half_switch = 0;
|
half_switch = 0;
|
||||||
}
|
}
|
||||||
if (GraphBuffer[i-1] > GraphBuffer[i]) dir=0;
|
if(i < GraphTraceLen)
|
||||||
else dir = 1;
|
{
|
||||||
}
|
if (GraphBuffer[i-1] > GraphBuffer[i]) dir=0;
|
||||||
if(bitidx==255)
|
else dir = 1;
|
||||||
bitidx=0;
|
}
|
||||||
warnings = 0;
|
}
|
||||||
if(num_blocks == 4) break;
|
if(bitidx==255)
|
||||||
|
bitidx=0;
|
||||||
|
warnings = 0;
|
||||||
|
if(num_blocks == 4) break;
|
||||||
}
|
}
|
||||||
memcpy(outBlocks, Blocks, 16*num_blocks);
|
memcpy(outBlocks, Blocks, 16*num_blocks);
|
||||||
return num_blocks;
|
return num_blocks;
|
||||||
|
|
|
@ -225,7 +225,7 @@ void FormatVersionInformation(char *dst, int len, const char *prefix, void *vers
|
||||||
{
|
{
|
||||||
struct version_information *v = (struct version_information*)version_information;
|
struct version_information *v = (struct version_information*)version_information;
|
||||||
dst[0] = 0;
|
dst[0] = 0;
|
||||||
strncat(dst, prefix, len);
|
strncat(dst, prefix, len-1);
|
||||||
if(v->magic != VERSION_INFORMATION_MAGIC) {
|
if(v->magic != VERSION_INFORMATION_MAGIC) {
|
||||||
strncat(dst, "Missing/Invalid version information", len - strlen(dst) - 1);
|
strncat(dst, "Missing/Invalid version information", len - strlen(dst) - 1);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue