mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-20 13:23:25 -07:00
More coverity fixes
This commit is contained in:
parent
0ce5620254
commit
ca4714cd23
6 changed files with 20 additions and 7 deletions
|
@ -667,12 +667,15 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
}
|
||||
if ((fkeys = fopen("dumpkeys.bin","rb")) == NULL) {
|
||||
PrintAndLog("Could not find file dumpkeys.bin");
|
||||
fclose(fdump);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
if (fread(keyA[sectorNo], 1, 6, fkeys) == 0) {
|
||||
PrintAndLog("File reading error (dumpkeys.bin).");
|
||||
fclose(fdump);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -680,9 +683,12 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
if (fread(keyB[sectorNo], 1, 6, fkeys) == 0) {
|
||||
PrintAndLog("File reading error (dumpkeys.bin).");
|
||||
fclose(fdump);
|
||||
fclose(fkeys);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
fclose(fkeys);
|
||||
|
||||
PrintAndLog("Restoring dumpdata.bin to card");
|
||||
|
||||
|
@ -693,6 +699,7 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
|
||||
if (fread(bldata, 1, 16, fdump) == 0) {
|
||||
PrintAndLog("File reading error (dumpdata.bin).");
|
||||
fclose(fdump);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -727,7 +734,6 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
}
|
||||
|
||||
fclose(fdump);
|
||||
fclose(fkeys);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,7 @@ void printarr_human_readable(char * title, uint8_t* arr, int len)
|
|||
cx += snprintf(output+cx,outsize-cx, "%02x ",*(arr+i));
|
||||
}
|
||||
prnlog(output);
|
||||
free(output);
|
||||
}
|
||||
|
||||
//-----------------------------
|
||||
|
|
|
@ -35,6 +35,7 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si
|
|||
FILE *fileHandle=fopen(fileName,"wb");
|
||||
if(!fileHandle) {
|
||||
prnlog("Failed to write to file '%s'", fileName);
|
||||
free(fileName);
|
||||
return 1;
|
||||
}
|
||||
fwrite(data, 1, datalen, fileHandle);
|
||||
|
|
|
@ -350,13 +350,15 @@ int loadTraceCard(uint8_t *tuid) {
|
|||
while(!feof(f)){
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (fgets(buf, sizeof(buf), f) == NULL) {
|
||||
PrintAndLog("File reading error.");
|
||||
PrintAndLog("File reading error.");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(buf) < 32){
|
||||
if (feof(f)) break;
|
||||
PrintAndLog("File content error. Block data must include 32 HEX symbols");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
for (i = 0; i < 32; i += 2)
|
||||
|
|
|
@ -73,6 +73,7 @@ serial_port uart_open(const char* pcPortName)
|
|||
// Does the system allows us to place a lock on this file descriptor
|
||||
if (fcntl(sp->fd, F_SETLK, &fl) == -1) {
|
||||
// A conflicting lock is held by another process
|
||||
free(sp);
|
||||
return CLAIMED_SERIAL_PORT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue