mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
fix valgrind memory bug
This commit is contained in:
parent
4b2c42aff8
commit
b754f09d24
1 changed files with 34 additions and 15 deletions
|
@ -387,20 +387,30 @@ static bool get_14b_UID(uint8_t *d, iso14b_type_t *found_type) {
|
||||||
* filename must match '^hf-14b-[0-9A-F]{16}'
|
* filename must match '^hf-14b-[0-9A-F]{16}'
|
||||||
*/
|
*/
|
||||||
uint8_t *get_uid_from_filename(const char *filename) {
|
uint8_t *get_uid_from_filename(const char *filename) {
|
||||||
|
|
||||||
static uint8_t uid[8];
|
static uint8_t uid[8];
|
||||||
memset(uid, 0, 8);
|
memset(uid, 0, 8);
|
||||||
char uidinhex[17] ;
|
|
||||||
if (strlen(filename) < 23 || strncmp(filename, "hf-14b-", 7)) {
|
if (strlen(filename) < 23) {
|
||||||
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
|
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *found = strstr(filename, "hf-14b-");
|
||||||
|
if (found == NULL) {
|
||||||
|
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
// extract uid part from filename
|
// extract uid part from filename
|
||||||
strncpy(uidinhex, filename + 7, 16) ;
|
char uidinhex[17] = {0};
|
||||||
|
strncpy(uidinhex, found + 7, 16);
|
||||||
|
|
||||||
uidinhex[16] = '\0';
|
uidinhex[16] = '\0';
|
||||||
int len = hex_to_bytes(uidinhex, uid, 8);
|
int len = hex_to_bytes(uidinhex, uid, 8);
|
||||||
if (len == 8)
|
if (len == 8) {
|
||||||
return SwapEndian64(uid, 8, 8);
|
return SwapEndian64(uid, 8, 8);
|
||||||
else {
|
} else {
|
||||||
PrintAndLogEx(ERR, "get_uid_from_filename failed: hex_to_bytes returned %d", len);
|
PrintAndLogEx(ERR, "get_uid_from_filename failed: hex_to_bytes returned %d", len);
|
||||||
memset(uid, 0, 8);
|
memset(uid, 0, 8);
|
||||||
}
|
}
|
||||||
|
@ -2471,11 +2481,20 @@ static int CmdHF14BAPDU(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "<<<< %s", sprint_hex(data, datalen));
|
PrintAndLogEx(INFO, "<<<< %s", sprint_hex(data, datalen));
|
||||||
|
uint16_t sw = get_sw(data, datalen);
|
||||||
|
if (sw != ISO7816_OK) {
|
||||||
PrintAndLogEx(SUCCESS, "APDU response: " _YELLOW_("%02x %02x") " - %s"
|
PrintAndLogEx(SUCCESS, "APDU response: " _YELLOW_("%02x %02x") " - %s"
|
||||||
, data[datalen - 2]
|
, data[datalen - 2]
|
||||||
, data[datalen - 1]
|
, data[datalen - 1]
|
||||||
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
|
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(SUCCESS, "APDU response: " _GREEN_("%02x %02x") " - %s"
|
||||||
|
, data[datalen - 2]
|
||||||
|
, data[datalen - 1]
|
||||||
|
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TLV decoder
|
// TLV decoder
|
||||||
if (decode_TLV && datalen > 4) {
|
if (decode_TLV && datalen > 4) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue