mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-29 14:52:19 +08:00
FIX: mem leaks
FIX: 'hf mf nested' - params
This commit is contained in:
parent
956899b839
commit
06ade9970a
6 changed files with 23 additions and 15 deletions
client
|
@ -834,6 +834,7 @@ int CmdHF15Restore(const char*Cmd) {
|
|||
|
||||
if (!getUID(uid)) {
|
||||
PrintAndLogEx(WARNING, "No tag found");
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
|
|
@ -425,6 +425,7 @@ char * GenerateFilename(const char *prefix, const char *suffix){
|
|||
GetHFMF14AUID(uid, &uidlen);
|
||||
if (!uidlen) {
|
||||
PrintAndLogEx(WARNING, "No tag found.");
|
||||
free(fptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1082,19 +1083,21 @@ int CmdHF14AMfNested(const char *Cmd) {
|
|||
} else {
|
||||
SectorsCnt = NumOfSectors(cmdp);
|
||||
}
|
||||
|
||||
ctmp = tolower(param_getchar(Cmd, 4));
|
||||
transferToEml |= (ctmp == 't');
|
||||
createDumpFile |= (ctmp == 'd');
|
||||
|
||||
ctmp = tolower(param_getchar(Cmd, 6));
|
||||
transferToEml |= (ctmp == 't');
|
||||
createDumpFile |= (ctmp == 'd');
|
||||
uint8_t j = 4;
|
||||
while ( ctmp != 0x00 ) {
|
||||
|
||||
ctmp = tolower(param_getchar(Cmd, j));
|
||||
transferToEml |= (ctmp == 't');
|
||||
createDumpFile |= (ctmp == 'd');
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
// check if we can authenticate to sector
|
||||
res = mfCheckKeys(blockNo, keyType, true, 1, key, &key64);
|
||||
if (res) {
|
||||
PrintAndLogEx(WARNING, "key is wrong. Can't authenticate to block:%3d key type:%c", blockNo, keyType ? 'B' : 'A');
|
||||
PrintAndLogEx(WARNING, "Wrong key. Can't authenticate to block:%3d key type:%c", blockNo, keyType ? 'B' : 'A');
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -1112,9 +1115,9 @@ int CmdHF14AMfNested(const char *Cmd) {
|
|||
if (transferToEml) {
|
||||
uint8_t sectortrailer;
|
||||
if (trgBlockNo < 32*4) { // 4 block sector
|
||||
sectortrailer = (trgBlockNo & ~0x03) + 3;
|
||||
sectortrailer = trgBlockNo | 0x03;
|
||||
} else { // 16 block sector
|
||||
sectortrailer = (trgBlockNo & ~0x0f) + 15;
|
||||
sectortrailer = trgBlockNo | 0x0f;
|
||||
}
|
||||
mfEmlGetMem(keyBlock, sectortrailer, 1);
|
||||
|
||||
|
@ -1236,7 +1239,7 @@ int CmdHF14AMfNested(const char *Cmd) {
|
|||
num_to_bytes(e_sector[i].Key[1], 6, &keyBlock[10]);
|
||||
mfEmlSetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "key transferred to emulator memory.");
|
||||
PrintAndLogEx(SUCCESS, "keys transferred to emulator memory.");
|
||||
}
|
||||
|
||||
// Create dump file
|
||||
|
|
|
@ -14,7 +14,6 @@ static int CmdHelp(const char *Cmd);
|
|||
// trace pointer
|
||||
static uint8_t *trace;
|
||||
long traceLen = 0;
|
||||
bool preRDV40 = true;
|
||||
|
||||
int usage_trace_list(){
|
||||
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
|
||||
|
@ -297,8 +296,9 @@ void printFelica(uint16_t traceLen, uint8_t *trace) {
|
|||
|
||||
if (tracepos + 3 >= traceLen) break;
|
||||
|
||||
uint16_t gap = (uint16_t)trace[tracepos+1] + ((uint16_t)trace[tracepos] >> 8);
|
||||
uint16_t crc_ok = trace[tracepos+2];
|
||||
|
||||
uint16_t gap = *((uint16_t *)(trace + tracepos));
|
||||
uint8_t crc_ok = trace[tracepos+2];
|
||||
tracepos += 3;
|
||||
|
||||
if (tracepos + 3 >= traceLen) break;
|
||||
|
|
|
@ -1204,6 +1204,7 @@ int CmdEMVExec(const char *cmd) {
|
|||
|
||||
if (res) {
|
||||
PrintAndLogEx(NORMAL, "AC1 error(%d): %4x. Exit...", res, sw);
|
||||
free(cdol1_data_tlv);
|
||||
dreturn(7);
|
||||
}
|
||||
|
||||
|
|
|
@ -685,6 +685,9 @@ static bool readKeyFile(uint8_t key[8]) {
|
|||
sprintf(filename, "%s.bin", "client/loclass/iclass_key");
|
||||
}
|
||||
|
||||
if ( filename == NULL )
|
||||
return retval;
|
||||
|
||||
FILE *f = fopen(filename, "rb");
|
||||
if (!f)
|
||||
return retval;
|
||||
|
|
|
@ -608,7 +608,7 @@ static int l_hardnested(lua_State *L){
|
|||
char filename[FILE_PATH_SIZE]="nonces.bin";
|
||||
const char *p_filename = luaL_checklstring(L, 11, &size);
|
||||
if(size != 0)
|
||||
strcpy(filename, p_filename);
|
||||
memcpy(filename, p_filename, FILE_PATH_SIZE-1);
|
||||
|
||||
uint32_t blockNo = 0, keyType = 0;
|
||||
uint32_t trgBlockNo = 0, trgKeyType = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue