mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-22 05:00:29 +08:00
FIX: Coverity Scan warnings on not using the fread return value.
This commit is contained in:
parent
52cf34c1cc
commit
841d7af0dc
5 changed files with 26 additions and 18 deletions
|
@ -1044,7 +1044,8 @@ int CmdHFiClassCloneTag(const char *Cmd) {
|
||||||
// else we have to create a share memory
|
// else we have to create a share memory
|
||||||
int i;
|
int i;
|
||||||
fseek(f,startblock*8,SEEK_SET);
|
fseek(f,startblock*8,SEEK_SET);
|
||||||
if ( fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f) == 0){
|
size_t bytes_read = fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f);
|
||||||
|
if ( bytes_read == 0){
|
||||||
PrintAndLog("File reading error.");
|
PrintAndLog("File reading error.");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -312,8 +312,10 @@ int CmdHF14AMfDump(const char *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read keys A from file
|
// Read keys A from file
|
||||||
|
size_t bytes_read;
|
||||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||||
if (fread( keyA[sectorNo], 1, 6, fin ) == 0) {
|
bytes_read = fread( keyA[sectorNo], 1, 6, fin );
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("File reading error.");
|
PrintAndLog("File reading error.");
|
||||||
fclose(fin);
|
fclose(fin);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -322,7 +324,8 @@ int CmdHF14AMfDump(const char *Cmd)
|
||||||
|
|
||||||
// Read keys B from file
|
// Read keys B from file
|
||||||
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
for (sectorNo=0; sectorNo<numSectors; sectorNo++) {
|
||||||
if (fread( keyB[sectorNo], 1, 6, fin ) == 0) {
|
bytes_read = fread( keyB[sectorNo], 1, 6, fin );
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("File reading error.");
|
PrintAndLog("File reading error.");
|
||||||
fclose(fin);
|
fclose(fin);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -479,8 +482,10 @@ int CmdHF14AMfRestore(const char *Cmd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t bytes_read;
|
||||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||||
if (fread(keyA[sectorNo], 1, 6, fkeys) == 0) {
|
bytes_read = fread( keyA[sectorNo], 1, 6, fkeys );
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("File reading error (dumpkeys.bin).");
|
PrintAndLog("File reading error (dumpkeys.bin).");
|
||||||
fclose(fkeys);
|
fclose(fkeys);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -488,7 +493,8 @@ int CmdHF14AMfRestore(const char *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||||
if (fread(keyB[sectorNo], 1, 6, fkeys) == 0) {
|
bytes_read = fread( keyB[sectorNo], 1, 6, fkeys );
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("File reading error (dumpkeys.bin).");
|
PrintAndLog("File reading error (dumpkeys.bin).");
|
||||||
fclose(fkeys);
|
fclose(fkeys);
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -626,7 +626,8 @@ static int read_nonce_file(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog("Reading nonces from file nonces.bin...");
|
PrintAndLog("Reading nonces from file nonces.bin...");
|
||||||
if (fread(read_buf, 1, 6, fnonces) == 0) {
|
size_t bytes_read = fread(read_buf, 1, 6, fnonces);
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("File reading error.");
|
PrintAndLog("File reading error.");
|
||||||
fclose(fnonces);
|
fclose(fnonces);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -173,7 +173,8 @@ int CmdLFHitagSim(const char *Cmd) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tag_mem_supplied = true;
|
tag_mem_supplied = true;
|
||||||
if (fread(c.d.asBytes,48,1,pf) == 0) {
|
size_t bytes_read = fread(c.d.asBytes, 48, 1, pf);
|
||||||
|
if ( bytes_read == 0) {
|
||||||
PrintAndLog("Error: File reading error");
|
PrintAndLog("Error: File reading error");
|
||||||
fclose(pf);
|
fclose(pf);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -740,14 +740,15 @@ int readKeyFile(uint8_t key[8])
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
f = fopen("iclass_key.bin", "rb");
|
f = fopen("iclass_key.bin", "rb");
|
||||||
if (f)
|
if (!f) {
|
||||||
{
|
return 0;
|
||||||
if(fread(key, sizeof(uint8_t), 8, f) == 1)
|
|
||||||
{
|
|
||||||
retval = 0;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t bytes_read = fread(key, sizeof(uint8_t), 8, f);
|
||||||
|
if ( bytes_read == 1) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,11 +759,9 @@ int doKeyTests(uint8_t debuglevel)
|
||||||
|
|
||||||
prnlog("[+] Checking if the master key is present (iclass_key.bin)...");
|
prnlog("[+] Checking if the master key is present (iclass_key.bin)...");
|
||||||
uint8_t key[8] = {0};
|
uint8_t key[8] = {0};
|
||||||
if(readKeyFile(key))
|
if(readKeyFile(key)) {
|
||||||
{
|
|
||||||
prnlog("[+] Master key not present, will not be able to do all testcases");
|
prnlog("[+] Master key not present, will not be able to do all testcases");
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
|
|
||||||
//Test if it's the right key...
|
//Test if it's the right key...
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
Loading…
Add table
Reference in a new issue