CHG: dropfield when CL is used.

This commit is contained in:
iceman1001 2019-01-29 15:42:31 +01:00
parent 384a44ce50
commit c419f7bf37
3 changed files with 27 additions and 23 deletions

View file

@ -623,7 +623,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
return 0;
}
#define dreturn(n) {free(pdol_data_tlv);tlvdb_free(tlvSelect);tlvdb_free(tlvRoot);DropField();return n;}
#define dreturn(n) {free(pdol_data_tlv); tlvdb_free(tlvSelect); tlvdb_free(tlvRoot); DropFieldEx( channel ); return n;}
void InitTransactionParameters(struct tlvdb *tlvRoot, bool paramLoadJSON, enum TransactionType TrType, bool GenACGPO) {
@ -1212,7 +1212,7 @@ int CmdEMVExec(const char *cmd) {
}
DropField();
DropFieldEx( channel );
// Destroy TLV's
free(pdol_data_tlv);
@ -1314,7 +1314,7 @@ int CmdEMVScan(const char *cmd) {
}
// drop field at start
DropField();
DropFieldEx( channel );
// iso 14443 select
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
@ -1367,7 +1367,7 @@ int CmdEMVScan(const char *cmd) {
if (EMVSearch(channel, false, true, decodeTLV, tlvSelect)) {
PrintAndLogEx(ERR, "Can't found any of EMV AID. Exit...");
tlvdb_free(tlvSelect);
DropField();
DropFieldEx( channel );
return 3;
}
@ -1383,7 +1383,7 @@ int CmdEMVScan(const char *cmd) {
if (!AIDlen) {
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
DropField();
DropFieldEx( channel );
return 4;
}
@ -1402,7 +1402,7 @@ int CmdEMVScan(const char *cmd) {
if (res) {
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 5;
}
@ -1430,7 +1430,7 @@ int CmdEMVScan(const char *cmd) {
if (!pdol_data_tlv){
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 6;
}
@ -1439,7 +1439,7 @@ int CmdEMVScan(const char *cmd) {
if (!pdol_data_tlv_data) {
PrintAndLogEx(ERR, "Can't create PDOL data.");
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 6;
}
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
@ -1453,7 +1453,7 @@ int CmdEMVScan(const char *cmd) {
if (res) {
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 7;
}
ProcessGPOResponseFormat1(tlvRoot, buf, len, decodeTLV);
@ -1545,8 +1545,7 @@ int CmdEMVScan(const char *cmd) {
// free tlv object
tlvdb_free(tlvRoot);
// DropField
DropField();
DropFieldEx( channel );
res = json_dump_file(root, fname, JSON_INDENT(2));
if (res) {
@ -1630,7 +1629,7 @@ int CmdEMVRoca(const char *cmd) {
if (EMVSearch(channel, false, true, false, tlvSelect)) {
PrintAndLogEx(ERR, "Can't found any of EMV AID. Exit...");
tlvdb_free(tlvSelect);
DropField();
DropFieldEx( channel );
return 3;
}
@ -1646,7 +1645,7 @@ int CmdEMVRoca(const char *cmd) {
if (!AIDlen) {
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
DropField();
DropFieldEx( channel );
return 4;
}
@ -1661,7 +1660,7 @@ int CmdEMVRoca(const char *cmd) {
if (res) {
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 5;
}
@ -1673,7 +1672,7 @@ int CmdEMVRoca(const char *cmd) {
if (!pdol_data_tlv){
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 6;
}
@ -1682,7 +1681,7 @@ int CmdEMVRoca(const char *cmd) {
if (!pdol_data_tlv_data) {
PrintAndLogEx(ERR, "Can't create PDOL data.");
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 6;
}
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
@ -1696,7 +1695,7 @@ int CmdEMVRoca(const char *cmd) {
if (res) {
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
tlvdb_free(tlvRoot);
DropField();
DropFieldEx( channel );
return 7;
}
ProcessGPOResponseFormat1(tlvRoot, buf, len, false);
@ -1794,10 +1793,7 @@ out:
// free tlv object
tlvdb_free(tlvRoot);
if ( channel == ECC_CONTACTLESS)
DropField();
DropFieldEx( channel );
return 0;
}

View file

@ -241,7 +241,7 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
int res = 0;
if (ActivateField) {
DropField();
DropFieldEx( channel );
msleep(50);
}
@ -484,7 +484,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
}
if(!LeaveFieldON)
DropField();
DropFieldEx( channel );
return res;
}

View file

@ -178,6 +178,14 @@
}
#endif
#ifndef DropFieldEx
#define DropFieldEx(x) { \
if ( (x) == ECC_CONTACTLESS) { \
DropField(); \
} \
}
#endif
extern uint8_t g_debugMode;
extern int ukbhit(void);