mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
fix: mem leaks
This commit is contained in:
parent
f0d5b79abb
commit
48a28fa575
3 changed files with 10 additions and 6 deletions
|
@ -1865,11 +1865,9 @@ int Cmdhex2bin(const char *Cmd) {
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Uses printf instead of PrintAndLog since the latter
|
//Uses printf instead of PrintAndLog since the latter adds linebreaks to each printout
|
||||||
// adds linebreaks to each printout - this way was more convenient since we don't have to
|
|
||||||
// allocate a string and write to that first...
|
|
||||||
for (int i = 0 ; i < 4 ; ++i)
|
for (int i = 0 ; i < 4 ; ++i)
|
||||||
PrintAndLogEx(NORMAL, "%d", (x >> (3 - i)) & 1);
|
printf("%d", (x >> (3 - i)) & 1);
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "\n");
|
PrintAndLogEx(NORMAL, "\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -351,7 +351,7 @@ static void printHitagConfiguration(uint8_t config) {
|
||||||
char bits[9];
|
char bits[9];
|
||||||
char *bs = bits;
|
char *bs = bits;
|
||||||
for (uint8_t i = 0 ; i < 8 ; i++) {
|
for (uint8_t i = 0 ; i < 8 ; i++) {
|
||||||
snprintf(bs, sizeof(bits), "%d", (config >> (7 - i)) & 1);
|
snprintf(bs, sizeof(bits) - i, "%1d", (config >> (7 - i)) & 1);
|
||||||
bs++;
|
bs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ static void printHitagConfiguration(uint8_t config) {
|
||||||
PrintAndLogEx(INFO, "------------------------------------");
|
PrintAndLogEx(INFO, "------------------------------------");
|
||||||
|
|
||||||
//configuration byte
|
//configuration byte
|
||||||
PrintAndLogEx(SUCCESS, "Config byte : %02X - %s", config, bits);
|
PrintAndLogEx(SUCCESS, "Config byte : 0x%02X [ %s ]", config, bits);
|
||||||
|
|
||||||
// encoding
|
// encoding
|
||||||
strcat(msg, "Encoding : ");
|
strcat(msg, "Encoding : ");
|
||||||
|
|
|
@ -667,6 +667,7 @@ int CmdSmartUpgrade(const char *Cmd) {
|
||||||
f = fopen(sha512filename, "rb");
|
f = fopen(sha512filename, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLogEx(FAILED, "SHA-512 file not found or locked.");
|
PrintAndLogEx(FAILED, "SHA-512 file not found or locked.");
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,12 +679,14 @@ int CmdSmartUpgrade(const char *Cmd) {
|
||||||
if (fsize < 0) {
|
if (fsize < 0) {
|
||||||
PrintAndLogEx(FAILED, "Could not determine size of SHA-512 file");
|
PrintAndLogEx(FAILED, "Could not determine size of SHA-512 file");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsize < 128) {
|
if (fsize < 128) {
|
||||||
PrintAndLogEx(FAILED, "SHA-512 file too short");
|
PrintAndLogEx(FAILED, "SHA-512 file too short");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,17 +700,20 @@ int CmdSmartUpgrade(const char *Cmd) {
|
||||||
uint8_t hash1[64];
|
uint8_t hash1[64];
|
||||||
if (bytes_read != 128 || param_gethex(hashstring, 0, hash1, 128)) {
|
if (bytes_read != 128 || param_gethex(hashstring, 0, hash1, 128)) {
|
||||||
PrintAndLogEx(FAILED, "Couldn't read SHA-512 file");
|
PrintAndLogEx(FAILED, "Couldn't read SHA-512 file");
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t hash2[64];
|
uint8_t hash2[64];
|
||||||
if (sha512hash(dump, firmware_size, hash2)) {
|
if (sha512hash(dump, firmware_size, hash2)) {
|
||||||
PrintAndLogEx(FAILED, "Couldn't calculate SHA-512 of firmware");
|
PrintAndLogEx(FAILED, "Couldn't calculate SHA-512 of firmware");
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(hash1, hash2, 64)) {
|
if (memcmp(hash1, hash2, 64)) {
|
||||||
PrintAndLogEx(FAILED, "Couldn't verify integrity of firmware file " _RED_("(wrong SHA-512 hash)"));
|
PrintAndLogEx(FAILED, "Couldn't verify integrity of firmware file " _RED_("(wrong SHA-512 hash)"));
|
||||||
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue