fix: mem leaks.
This commit is contained in:
@@ -299,10 +299,10 @@ uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace,uint16_t tracelen) {
|
||||
char idm[20];
|
||||
char pmm[20];
|
||||
for (int j = 0; j < 8; j++)
|
||||
snprintf(idm+( j * 2),20, "%02x", trace[j+3]);
|
||||
snprintf(idm + (j * 2), 20, "%02x", trace[j+3]);
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
snprintf(pmm+( j * 2),20, "%02x", trace[j+11]);
|
||||
snprintf(pmm + (j * 2), 20, "%02x", trace[j+11]);
|
||||
|
||||
PrintAndLogEx(NORMAL, "DeviceId: IDm: 0x%s PMm: 0x%s ", idm, pmm);
|
||||
}
|
||||
|
||||
@@ -2162,10 +2162,10 @@ static int cmp_uint32( const void *a, const void *b) {
|
||||
int CmdHFiClassLookUp(const char *Cmd) {
|
||||
|
||||
uint8_t CSN[8];
|
||||
uint8_t EPURSE[8];
|
||||
uint8_t EPURSE[8] = { 0,0,0,0,0,0,0,0 };
|
||||
uint8_t MACS[8];
|
||||
uint8_t CCNR[12];
|
||||
uint8_t MAC_TAG[4] = {0x00,0x00,0x00,0x00};
|
||||
uint8_t MAC_TAG[4] = { 0,0,0,0 };
|
||||
|
||||
// elite key, raw key, standard key
|
||||
bool use_elite = false;
|
||||
|
||||
@@ -1022,6 +1022,7 @@ int CmdLegicRestore(const char *Cmd){
|
||||
f = fopen(filename,"rb");
|
||||
if (!f) {
|
||||
PrintAndLogEx(WARNING, "File %s not found or locked", filename);
|
||||
free(data);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,14 +266,20 @@ static void init_bitflip_bitarrays(void)
|
||||
continue;
|
||||
} else {
|
||||
fseek(statesfile, 0, SEEK_END);
|
||||
uint32_t filesize = (uint32_t)ftell(statesfile);
|
||||
int fsize = ftell(statesfile);
|
||||
if ( fsize == -1 ){
|
||||
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
|
||||
fclose(statesfile);
|
||||
exit(5);
|
||||
}
|
||||
uint32_t filesize = (uint32_t)fsize;
|
||||
rewind(statesfile);
|
||||
uint8_t input_buffer[filesize];
|
||||
size_t bytesread = fread(input_buffer, 1, filesize, statesfile);
|
||||
if (bytesread != filesize) {
|
||||
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
|
||||
fclose(statesfile);
|
||||
inflateEnd(&compressed_stream);
|
||||
//inflateEnd(&compressed_stream);
|
||||
exit(5);
|
||||
}
|
||||
fclose(statesfile);
|
||||
|
||||
@@ -284,6 +284,7 @@ int CmdEMVGPO(const char *cmd) {
|
||||
if (!pdol_data_tlv_data) {
|
||||
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
||||
tlvdb_free(tlvRoot);
|
||||
free(pdol_data_tlv);
|
||||
return 4;
|
||||
}
|
||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||
@@ -296,6 +297,7 @@ int CmdEMVGPO(const char *cmd) {
|
||||
|
||||
if (pdol_data_tlv != &data_tlv)
|
||||
free(pdol_data_tlv);
|
||||
|
||||
tlvdb_free(tlvRoot);
|
||||
|
||||
if (sw)
|
||||
|
||||
@@ -429,9 +429,6 @@ char *emv_pk_get_ca_pk_file(const char *dirname, const unsigned char *rid, unsig
|
||||
if (!dirname)
|
||||
dirname = ".";//openemv_config_get_str("capk.dir", NULL);
|
||||
|
||||
if (!dirname)
|
||||
return NULL;
|
||||
|
||||
char *filename;
|
||||
int ret = asprintf(&filename, "%s/%02hhx%02hhx%02hhx%02hhx%02hhx_%02hhx.0",
|
||||
dirname,
|
||||
@@ -453,9 +450,6 @@ char *emv_pk_get_ca_pk_rid_file(const char *dirname, const unsigned char *rid)
|
||||
if (!dirname)
|
||||
dirname = "."; //openemv_config_get_str("capk.dir", NULL);
|
||||
|
||||
if (!dirname)
|
||||
return NULL;
|
||||
|
||||
char *filename;
|
||||
int ret = asprintf(&filename, "%s/%02hhx%02hhx%02hhx%02hhx%02hhx.pks",
|
||||
dirname,
|
||||
|
||||
@@ -311,6 +311,11 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
|
||||
|
||||
uint64_t start_time = msclock();
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
if ( NUM_BRUTE_FORCE_THREADS < 0 )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
pthread_t threads[NUM_BRUTE_FORCE_THREADS];
|
||||
struct args {
|
||||
bool silent;
|
||||
@@ -322,7 +327,7 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
|
||||
uint8_t *best_first_bytes;
|
||||
} thread_args[NUM_BRUTE_FORCE_THREADS];
|
||||
|
||||
for(uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
|
||||
for (uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
|
||||
thread_args[i].thread_ID = i;
|
||||
thread_args[i].silent = silent;
|
||||
thread_args[i].cuid = cuid;
|
||||
@@ -332,7 +337,7 @@ bool brute_force_bs(float *bf_rate, statelist_t *candidates, uint32_t cuid, uint
|
||||
thread_args[i].best_first_bytes = best_first_bytes;
|
||||
pthread_create(&threads[i], NULL, crack_states_thread, (void*)&thread_args[i]);
|
||||
}
|
||||
for(uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
|
||||
for (uint32_t i = 0; i < NUM_BRUTE_FORCE_THREADS; i++){
|
||||
pthread_join(threads[i], 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user