From a6977860db5d21ce160e91462dfbf10e9f1bdade Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 17 Jul 2019 11:27:05 +0300 Subject: [PATCH] fix emv search keep field bug --- client/emv/emvcore.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/emv/emvcore.c b/client/emv/emvcore.c index fd70ca871..178a18d58 100644 --- a/client/emv/emvcore.c +++ b/client/emv/emvcore.c @@ -532,7 +532,7 @@ int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, int retrycnt = 0; for (int i = 0; i < AIDlistLen; i ++) { param_gethex_to_eol(AIDlist[i].aid, 0, aidbuf, sizeof(aidbuf), &aidlen); - res = EMVSelect(channel, (i == 0) ? ActivateField : false, (i == AIDlistLen - 1) ? LeaveFieldON : true, aidbuf, aidlen, data, sizeof(data), &datalen, &sw, tlv); + res = EMVSelect(channel, (i == 0) ? ActivateField : false, true, aidbuf, aidlen, data, sizeof(data), &datalen, &sw, tlv); // retry if error and not returned sw error if (res && res != 5) { if (++retrycnt < 3) { @@ -540,6 +540,9 @@ int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, } else { // (1) - card select error, proxmark error OR (200) - result length = 0 if (res == 1 || res == 200) { + if (!LeaveFieldON) + DropFieldEx(channel); + PrintAndLogEx(WARNING, "Exit..."); return 1; } @@ -563,6 +566,9 @@ int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, } } + if (!LeaveFieldON) + DropFieldEx(channel); + return 0; }