Coverity-fixes in armsrc

This commit is contained in:
Martin Holst Swende 2014-10-28 21:44:17 +01:00
commit 2ed270a854
6 changed files with 104 additions and 91 deletions

View file

@ -419,7 +419,7 @@ int EPA_Setup()
// return code
int return_code = 0;
// card UID
uint8_t uid[8];
uint8_t uid[10];
// card select information
iso14a_card_select_t card_select_info;
// power up the field

View file

@ -1158,7 +1158,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
case RHT2F_CRYPTO: {
DbpString("Authenticating using key:");
memcpy(key,htd->crypto.key,6);
memcpy(key,htd->crypto.key,4);
Dbhexdump(6,key,false);
blocknr = 0;
bQuiet = false;

View file

@ -1295,8 +1295,8 @@ static void TransmitIClassCommand(const uint8_t *cmd, int len, int *samples, int
FpgaSetupSsc();
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)) {
@ -1310,6 +1310,9 @@ static void TransmitIClassCommand(const uint8_t *cmd, int len, int *samples, int
WDT_HIT();
}
}
uint8_t sendbyte;
bool firstpart = TRUE;
c = 0;

View file

@ -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 */) {
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
// http://www.nxp.com/documents/application_note/AN10927.pdf
memcpy(uid_resp, uid_resp + 1, 3);
// This was earlier:
//memcpy(uid_resp, uid_resp + 1, 3);
// But memcpy should not be used for overlapping arrays,
// and memmove appears to not be available in the arm build.
// So this has been replaced with a for-loop:
for(int xx = 0; xx < 3; xx++) uid_resp[xx] = uid_resp[xx+1];
uid_resp_len = 3;
}
@ -1936,7 +1942,8 @@ void ReaderMifare(bool first_try)
uint8_t uid[10];
uint32_t cuid;
uint32_t nt, previous_nt;
uint32_t nt =0 ;
uint32_t previous_nt = 0;
static uint32_t nt_attacked = 0;
byte_t par_list[8] = {0,0,0,0,0,0,0,0};
byte_t ks_list[8] = {0,0,0,0,0,0,0,0};

View file

@ -1521,9 +1521,12 @@ int DemodPCF7931(uint8_t **outBlocks) {
block_done = 0;
half_switch = 0;
}
if(i < GraphTraceLen)
{
if (GraphBuffer[i-1] > GraphBuffer[i]) dir=0;
else dir = 1;
}
}
if(bitidx==255)
bitidx=0;
warnings = 0;

View file

@ -225,7 +225,7 @@ void FormatVersionInformation(char *dst, int len, const char *prefix, void *vers
{
struct version_information *v = (struct version_information*)version_information;
dst[0] = 0;
strncat(dst, prefix, len);
strncat(dst, prefix, len-1);
if(v->magic != VERSION_INFORMATION_MAGIC) {
strncat(dst, "Missing/Invalid version information", len - strlen(dst) - 1);
return;